clean up a bit
This commit is contained in:
@@ -8,6 +8,7 @@ namespace Apollon.Domain.Models
|
|||||||
{
|
{
|
||||||
public class Competition
|
public class Competition
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
public string CompetitionName{ get; set; }
|
public string CompetitionName{ get; set; }
|
||||||
public string CompetitionImage{ get; set; }
|
public string CompetitionImage{ get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework
|
namespace Apollon.EntityFramework
|
||||||
{
|
{
|
||||||
public class TournamentsDbContext : DbContext
|
public class ApplicationDbContext : DbContext
|
||||||
{
|
{
|
||||||
public TournamentsDbContext(DbContextOptions options) : base(options)
|
public ApplicationDbContext(DbContextOptions options) : base(options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public DbSet<TournamentDto> Tournaments { get; set; }
|
public DbSet<TournamentDto> Tournaments { get; set; }
|
||||||
|
public DbSet<CompetitionDto> Competition { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,18 +7,18 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework
|
namespace Apollon.EntityFramework
|
||||||
{
|
{
|
||||||
public class TournamentsDbContextFactory
|
public class ApplicationDBContextFactory
|
||||||
{
|
{
|
||||||
private readonly DbContextOptions _options;
|
private readonly DbContextOptions _options;
|
||||||
|
|
||||||
public TournamentsDbContextFactory(DbContextOptions options)
|
public ApplicationDBContextFactory(DbContextOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TournamentsDbContext Create()
|
public ApplicationDbContext Create()
|
||||||
{
|
{
|
||||||
return new TournamentsDbContext(_options);
|
return new ApplicationDbContext(_options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,12 +8,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework
|
namespace Apollon.EntityFramework
|
||||||
{
|
{
|
||||||
public class TournamentsDesignTimeDbContextFactory : IDesignTimeDbContextFactory<TournamentsDbContext>
|
public class ApplicationDesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
|
||||||
{
|
{
|
||||||
|
|
||||||
public TournamentsDbContext CreateDbContext(string[] args = null)
|
public ApplicationDbContext CreateDbContext(string[] args = null)
|
||||||
{
|
{
|
||||||
return new TournamentsDbContext(new DbContextOptionsBuilder().UseSqlServer("Server=NATHALIE-PC\\NATLINUXDB;Database=Apollon;Trusted_Connection=True;MultipleActiveResultSets=true").Options);
|
return new ApplicationDbContext(new DbContextOptionsBuilder().UseSqlServer("Server=NATHALIE-PC\\NATLINUXDB;Database=Apollon;Trusted_Connection=True;MultipleActiveResultSets=true").Options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,16 +12,16 @@ namespace Apollon.EntityFramework.Commands
|
|||||||
{
|
{
|
||||||
public class CreateTournamentCommand : ICreateTournamentCommand
|
public class CreateTournamentCommand : ICreateTournamentCommand
|
||||||
{
|
{
|
||||||
private readonly TournamentsDbContextFactory _contextFactory;
|
private readonly ApplicationDBContextFactory _contextFactory;
|
||||||
|
|
||||||
public CreateTournamentCommand(TournamentsDbContextFactory contextFactory)
|
public CreateTournamentCommand(ApplicationDBContextFactory contextFactory)
|
||||||
{
|
{
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(Tournament tournament)
|
public async Task Execute(Tournament tournament)
|
||||||
{
|
{
|
||||||
using (TournamentsDbContext context = _contextFactory.Create())
|
using (ApplicationDbContext context = _contextFactory.Create())
|
||||||
{
|
{
|
||||||
TournamentDto tournamentDto = new TournamentDto()
|
TournamentDto tournamentDto = new TournamentDto()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ namespace Apollon.EntityFramework.Commands
|
|||||||
{
|
{
|
||||||
public class DeleteTournamentCommand : IDeleteTournamentCommand
|
public class DeleteTournamentCommand : IDeleteTournamentCommand
|
||||||
{
|
{
|
||||||
private readonly TournamentsDbContextFactory _contextFactory;
|
private readonly ApplicationDBContextFactory _contextFactory;
|
||||||
|
|
||||||
public DeleteTournamentCommand(TournamentsDbContextFactory contextFactory)
|
public DeleteTournamentCommand(ApplicationDBContextFactory contextFactory)
|
||||||
{
|
{
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(Guid id)
|
public async Task Execute(Guid id)
|
||||||
{
|
{
|
||||||
using (TournamentsDbContext context = _contextFactory.Create())
|
using (ApplicationDbContext context = _contextFactory.Create())
|
||||||
{
|
{
|
||||||
TournamentDto tournamentDto = new TournamentDto()
|
TournamentDto tournamentDto = new TournamentDto()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ namespace Apollon.EntityFramework.Commands
|
|||||||
{
|
{
|
||||||
public class UpdateTournamentCommand : IUpdateTournamentCommand
|
public class UpdateTournamentCommand : IUpdateTournamentCommand
|
||||||
{
|
{
|
||||||
private readonly TournamentsDbContextFactory _contextFactory;
|
private readonly ApplicationDBContextFactory _contextFactory;
|
||||||
|
|
||||||
public UpdateTournamentCommand(TournamentsDbContextFactory contextFactory)
|
public UpdateTournamentCommand(ApplicationDBContextFactory contextFactory)
|
||||||
{
|
{
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(Tournament tournament)
|
public async Task Execute(Tournament tournament)
|
||||||
{
|
{
|
||||||
using (TournamentsDbContext context = _contextFactory.Create())
|
using (ApplicationDbContext context = _contextFactory.Create())
|
||||||
{
|
{
|
||||||
TournamentDto tournamentDto = new TournamentDto()
|
TournamentDto tournamentDto = new TournamentDto()
|
||||||
{
|
{
|
||||||
|
|||||||
15
Apollon.EntityFramework/DTOs/CompetitionDto.cs
Normal file
15
Apollon.EntityFramework/DTOs/CompetitionDto.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.EntityFramework.DTOs
|
||||||
|
{
|
||||||
|
public class CompetitionDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string CompetitionName { get; set; }
|
||||||
|
public string CompetitionImage { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework.Migrations
|
namespace Apollon.EntityFramework.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(TournamentsDbContext))]
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
[Migration("20220820005557_initial")]
|
[Migration("20220820005557_initial")]
|
||||||
partial class initial
|
partial class initial
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework.Migrations
|
namespace Apollon.EntityFramework.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(TournamentsDbContext))]
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
[Migration("20220828165744_initial1")]
|
[Migration("20220828165744_initial1")]
|
||||||
partial class initial1
|
partial class initial1
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework.Migrations
|
namespace Apollon.EntityFramework.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(TournamentsDbContext))]
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
[Migration("20221107194347_competition")]
|
[Migration("20221107194347_competition")]
|
||||||
partial class competition
|
partial class competition
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework.Migrations
|
namespace Apollon.EntityFramework.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(TournamentsDbContext))]
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
[Migration("20221110003817_logo")]
|
[Migration("20221110003817_logo")]
|
||||||
partial class logo
|
partial class logo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework.Migrations
|
namespace Apollon.EntityFramework.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(TournamentsDbContext))]
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
partial class TournamentsDbContextModelSnapshot : ModelSnapshot
|
partial class TournamentsDbContextModelSnapshot : ModelSnapshot
|
||||||
{
|
{
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ namespace Apollon.EntityFramework.Queries
|
|||||||
{
|
{
|
||||||
public class GetAllTournamentsQuery : IGetAllTournamentsQuery
|
public class GetAllTournamentsQuery : IGetAllTournamentsQuery
|
||||||
{
|
{
|
||||||
private readonly TournamentsDbContextFactory _contextFactory;
|
private readonly ApplicationDBContextFactory _contextFactory;
|
||||||
|
|
||||||
public GetAllTournamentsQuery(TournamentsDbContextFactory contextFactory)
|
public GetAllTournamentsQuery(ApplicationDBContextFactory contextFactory)
|
||||||
{
|
{
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Tournament>> Execute()
|
public async Task<IEnumerable<Tournament>> Execute()
|
||||||
{
|
{
|
||||||
using (TournamentsDbContext context = _contextFactory.Create())
|
using (ApplicationDbContext context = _contextFactory.Create())
|
||||||
{
|
{
|
||||||
IEnumerable<TournamentDto> tournamentsDtos = await context.Tournaments.ToListAsync();
|
IEnumerable<TournamentDto> tournamentsDtos = await context.Tournaments.ToListAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Apollon.WPF
|
|||||||
{
|
{
|
||||||
private readonly NavigationStore _navigationStore;
|
private readonly NavigationStore _navigationStore;
|
||||||
private readonly ModalNavigationStore _modalNavigationStore;
|
private readonly ModalNavigationStore _modalNavigationStore;
|
||||||
private readonly TournamentsDbContextFactory _tournamentsDbContextFactory;
|
private readonly ApplicationDBContextFactory _tournamentsDbContextFactory;
|
||||||
private readonly IGetAllTournamentsQuery _getAllTournamentQuery;
|
private readonly IGetAllTournamentsQuery _getAllTournamentQuery;
|
||||||
private readonly ICreateTournamentCommand _createTournamentCommand;
|
private readonly ICreateTournamentCommand _createTournamentCommand;
|
||||||
private readonly IUpdateTournamentCommand _updateTournamentCommand;
|
private readonly IUpdateTournamentCommand _updateTournamentCommand;
|
||||||
@@ -38,7 +38,7 @@ namespace Apollon.WPF
|
|||||||
|
|
||||||
_navigationStore = new NavigationStore();
|
_navigationStore = new NavigationStore();
|
||||||
_modalNavigationStore = new ModalNavigationStore();
|
_modalNavigationStore = new ModalNavigationStore();
|
||||||
_tournamentsDbContextFactory = new TournamentsDbContextFactory(
|
_tournamentsDbContextFactory = new ApplicationDBContextFactory(
|
||||||
new DbContextOptionsBuilder().UseSqlServer(connectionString).Options);
|
new DbContextOptionsBuilder().UseSqlServer(connectionString).Options);
|
||||||
_getAllTournamentQuery = new GetAllTournamentsQuery(_tournamentsDbContextFactory);
|
_getAllTournamentQuery = new GetAllTournamentsQuery(_tournamentsDbContextFactory);
|
||||||
_createTournamentCommand = new CreateTournamentCommand(_tournamentsDbContextFactory);
|
_createTournamentCommand = new CreateTournamentCommand(_tournamentsDbContextFactory);
|
||||||
@@ -49,7 +49,7 @@ namespace Apollon.WPF
|
|||||||
}
|
}
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
using(TournamentsDbContext context = _tournamentsDbContextFactory.Create())
|
using(ApplicationDbContext context = _tournamentsDbContextFactory.Create())
|
||||||
{
|
{
|
||||||
context.Database.Migrate();
|
context.Database.Migrate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace Apollon.WPF.ViewModels
|
|||||||
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand)
|
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Logo = tournament.Logo,
|
||||||
Organisation = tournament.Organisation,
|
Organisation = tournament.Organisation,
|
||||||
TournamentName = tournament.TournamentName,
|
TournamentName = tournament.TournamentName,
|
||||||
Competition = tournament.Competition,
|
Competition = tournament.Competition,
|
||||||
|
|||||||
Reference in New Issue
Block a user