before migration
This commit is contained in:
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.8" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.8">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.8" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ namespace Apollon.EntityFramework.Commands
|
|||||||
public class CreateTournamentCommand : ICreateTournamentCommand
|
public class CreateTournamentCommand : ICreateTournamentCommand
|
||||||
|
|
||||||
{
|
{
|
||||||
private readonly TournamentsDBContextFactory _contextFactory;
|
private readonly TournamentsDbContextFactory _contextFactory;
|
||||||
|
|
||||||
public CreateTournamentCommand(TournamentsDBContextFactory contextFactory)
|
public CreateTournamentCommand(TournamentsDbContextFactory contextFactory)
|
||||||
{
|
{
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(Tournament tournament)
|
public async Task Execute(Tournament tournament)
|
||||||
{
|
{
|
||||||
using (TournamentsDBContext context = _contextFactory.Create())
|
using (TournamentsDbContext 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 TournamentsDbContextFactory _contextFactory;
|
||||||
|
|
||||||
public DeleteTournamentCommand(TournamentsDBContextFactory contextFactory)
|
public DeleteTournamentCommand(TournamentsDbContextFactory contextFactory)
|
||||||
{
|
{
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(Guid id)
|
public async Task Execute(Guid id)
|
||||||
{
|
{
|
||||||
using (TournamentsDBContext context = _contextFactory.Create())
|
using (TournamentsDbContext 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 TournamentsDbContextFactory _contextFactory;
|
||||||
|
|
||||||
public UpdateTournamentCommand(TournamentsDBContextFactory contextFactory)
|
public UpdateTournamentCommand(TournamentsDbContextFactory contextFactory)
|
||||||
{
|
{
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(Tournament tournament)
|
public async Task Execute(Tournament tournament)
|
||||||
{
|
{
|
||||||
using (TournamentsDBContext context = _contextFactory.Create())
|
using (TournamentsDbContext context = _contextFactory.Create())
|
||||||
{
|
{
|
||||||
TournamentDto tournamentDto = new TournamentDto()
|
TournamentDto tournamentDto = new TournamentDto()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ namespace Apollon.EntityFramework.Queries
|
|||||||
{
|
{
|
||||||
public class GetAllTournamentsQuery : IGetAllTournamentsQuery
|
public class GetAllTournamentsQuery : IGetAllTournamentsQuery
|
||||||
{
|
{
|
||||||
private readonly TournamentsDBContextFactory _contextFactory;
|
private readonly TournamentsDbContextFactory _contextFactory;
|
||||||
|
|
||||||
public GetAllTournamentsQuery(TournamentsDBContextFactory contextFactory)
|
public GetAllTournamentsQuery(TournamentsDbContextFactory contextFactory)
|
||||||
{
|
{
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Tournament>> Execute()
|
public async Task<IEnumerable<Tournament>> Execute()
|
||||||
{
|
{
|
||||||
using (TournamentsDBContext context = _contextFactory.Create())
|
using (TournamentsDbContext context = _contextFactory.Create())
|
||||||
{
|
{
|
||||||
IEnumerable<TournamentDto> tournamentsDtos = await context.Tournaments.ToListAsync();
|
IEnumerable<TournamentDto> tournamentsDtos = await context.Tournaments.ToListAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework
|
namespace Apollon.EntityFramework
|
||||||
{
|
{
|
||||||
public class TournamentsDBContext : DbContext
|
public class TournamentsDbContext : DbContext
|
||||||
{
|
{
|
||||||
public TournamentsDBContext(DbContextOptions options) : base(options)
|
public TournamentsDbContext(DbContextOptions options) : base(options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,18 +7,18 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Apollon.EntityFramework
|
namespace Apollon.EntityFramework
|
||||||
{
|
{
|
||||||
public class TournamentsDBContextFactory
|
public class TournamentsDbContextFactory
|
||||||
{
|
{
|
||||||
private readonly DbContextOptions _options;
|
private readonly DbContextOptions _options;
|
||||||
|
|
||||||
public TournamentsDBContextFactory(DbContextOptions options)
|
public TournamentsDbContextFactory(DbContextOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TournamentsDBContext Create()
|
public TournamentsDbContext Create()
|
||||||
{
|
{
|
||||||
return new TournamentsDBContext(_options);
|
return new TournamentsDbContext(_options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.EntityFramework
|
||||||
|
{
|
||||||
|
public class TournamentsDbContextFactory
|
||||||
|
{
|
||||||
|
private readonly DbContextOptions _options;
|
||||||
|
|
||||||
|
public TournamentsDbContextFactory(DbContextOptions options)
|
||||||
|
{
|
||||||
|
_options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TournamentsDbContext Create()
|
||||||
|
{
|
||||||
|
return new TournamentsDbContext(_options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Apollon.Domain\Apollon.Domain.csproj" />
|
<ProjectReference Include="..\Apollon.Domain\Apollon.Domain.csproj" />
|
||||||
|
<ProjectReference Include="..\Apollon.EntityFramework\Apollon.EntityFramework.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace Apollon.WPF
|
|||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
private readonly ModalNavigationStore _modalNavigationStore;
|
private readonly ModalNavigationStore _modalNavigationStore;
|
||||||
private readonly TournamentsDBContextFactory _tournamentsDBContextFactory;
|
private readonly TournamentsDbContextFactory _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;
|
||||||
@@ -34,15 +34,15 @@ namespace Apollon.WPF
|
|||||||
|
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
string connectionString = "Server=NATHALIE-PC\NATLINUXDB;Database=OfficeOrganizer;Trusted_Connection=True;MultipleActiveResultSets=true\";
|
string connectionString = "Data Source=NATHALIE-PC\\NATLINUXDB;Database=Apollon;Trusted_Connection=True;MultipleActiveResultSets=true";
|
||||||
|
|
||||||
_modalNavigationStore = new ModalNavigationStore();
|
_modalNavigationStore = new ModalNavigationStore();
|
||||||
_tournamentsDBContextFactory = new TournamentsDBContextFactory(
|
_tournamentsDbContextFactory = new TournamentsDbContextFactory(
|
||||||
new DbContextOptionsBuilder().UseSqlServer(connectionString).Options);
|
new DbContextOptionsBuilder().UseSqlServer(connectionString).Options);
|
||||||
_getAllTournamentQuery = new GetAllTournamentsQuery();
|
_getAllTournamentQuery = new GetAllTournamentsQuery(_tournamentsDbContextFactory);
|
||||||
_createTournamentCommand = new CreateTournamentCommand();
|
_createTournamentCommand = new CreateTournamentCommand(_tournamentsDbContextFactory);
|
||||||
_updateTournamentCommand = new UpdateTournamentCommand();
|
_updateTournamentCommand = new UpdateTournamentCommand(_tournamentsDbContextFactory);
|
||||||
_deleteTournamentCommand = new DeleteTournamentCommand();
|
_deleteTournamentCommand = new DeleteTournamentCommand(_tournamentsDbContextFactory);
|
||||||
_tournamentStore = new TournamentsStore(_getAllTournamentQuery, _createTournamentCommand, _updateTournamentCommand, _deleteTournamentCommand);
|
_tournamentStore = new TournamentsStore(_getAllTournamentQuery, _createTournamentCommand, _updateTournamentCommand, _deleteTournamentCommand);
|
||||||
_selectedTournamentStore = new SelectedTournamentsStore(_tournamentStore);
|
_selectedTournamentStore = new SelectedTournamentsStore(_tournamentStore);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Apollon.Domain.Models;
|
using Apollon.Domain.Commands;
|
||||||
|
using Apollon.Domain.Models;
|
||||||
|
using Apollon.Domain.Queries;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -9,16 +11,34 @@ namespace Apollon.WPF.Stores
|
|||||||
{
|
{
|
||||||
public class TournamentsStore
|
public class TournamentsStore
|
||||||
{
|
{
|
||||||
|
private readonly IGetAllTournamentsQuery _getAllTournamentQuery;
|
||||||
|
private readonly ICreateTournamentCommand _createTournamentCommand;
|
||||||
|
private readonly IUpdateTournamentCommand _updateTournamentCommand;
|
||||||
|
private readonly IDeleteTournamentCommand _deleteTournamentCommand;
|
||||||
|
|
||||||
|
public TournamentsStore(IGetAllTournamentsQuery getAllTournamentQuery,
|
||||||
|
ICreateTournamentCommand createTournamentCommand,
|
||||||
|
IUpdateTournamentCommand updateTournamentCommand,
|
||||||
|
IDeleteTournamentCommand deleteTournamentCommand)
|
||||||
|
{
|
||||||
|
_getAllTournamentQuery = getAllTournamentQuery;
|
||||||
|
_createTournamentCommand = createTournamentCommand;
|
||||||
|
_updateTournamentCommand = updateTournamentCommand;
|
||||||
|
_deleteTournamentCommand = deleteTournamentCommand;
|
||||||
|
}
|
||||||
|
|
||||||
public event Action<Tournament> TournamentAdded;
|
public event Action<Tournament> TournamentAdded;
|
||||||
public event Action<Tournament> TournamentUpdated;
|
public event Action<Tournament> TournamentUpdated;
|
||||||
|
|
||||||
public async Task Add(Tournament tournament)
|
public async Task Add(Tournament tournament)
|
||||||
{
|
{
|
||||||
|
await _createTournamentCommand.Execute(tournament);
|
||||||
TournamentAdded?.Invoke(tournament);
|
TournamentAdded?.Invoke(tournament);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Update (Tournament tournament)
|
public async Task Update (Tournament tournament)
|
||||||
{
|
{
|
||||||
|
await _updateTournamentCommand.Execute(tournament);
|
||||||
TournamentUpdated?.Invoke(tournament);
|
TournamentUpdated?.Invoke(tournament);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user