clean up a bit
This commit is contained in:
@@ -8,11 +8,12 @@ using System.Threading.Tasks;
|
||||
|
||||
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<CompetitionDto> Competition { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,18 +7,18 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Apollon.EntityFramework
|
||||
{
|
||||
public class TournamentsDbContextFactory
|
||||
public class ApplicationDBContextFactory
|
||||
{
|
||||
private readonly DbContextOptions _options;
|
||||
|
||||
public TournamentsDbContextFactory(DbContextOptions options)
|
||||
public ApplicationDBContextFactory(DbContextOptions 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
|
||||
{
|
||||
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
|
||||
{
|
||||
private readonly TournamentsDbContextFactory _contextFactory;
|
||||
private readonly ApplicationDBContextFactory _contextFactory;
|
||||
|
||||
public CreateTournamentCommand(TournamentsDbContextFactory contextFactory)
|
||||
public CreateTournamentCommand(ApplicationDBContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public async Task Execute(Tournament tournament)
|
||||
{
|
||||
using (TournamentsDbContext context = _contextFactory.Create())
|
||||
using (ApplicationDbContext context = _contextFactory.Create())
|
||||
{
|
||||
TournamentDto tournamentDto = new TournamentDto()
|
||||
{
|
||||
|
||||
@@ -11,16 +11,16 @@ namespace Apollon.EntityFramework.Commands
|
||||
{
|
||||
public class DeleteTournamentCommand : IDeleteTournamentCommand
|
||||
{
|
||||
private readonly TournamentsDbContextFactory _contextFactory;
|
||||
private readonly ApplicationDBContextFactory _contextFactory;
|
||||
|
||||
public DeleteTournamentCommand(TournamentsDbContextFactory contextFactory)
|
||||
public DeleteTournamentCommand(ApplicationDBContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public async Task Execute(Guid id)
|
||||
{
|
||||
using (TournamentsDbContext context = _contextFactory.Create())
|
||||
using (ApplicationDbContext context = _contextFactory.Create())
|
||||
{
|
||||
TournamentDto tournamentDto = new TournamentDto()
|
||||
{
|
||||
|
||||
@@ -11,16 +11,16 @@ namespace Apollon.EntityFramework.Commands
|
||||
{
|
||||
public class UpdateTournamentCommand : IUpdateTournamentCommand
|
||||
{
|
||||
private readonly TournamentsDbContextFactory _contextFactory;
|
||||
private readonly ApplicationDBContextFactory _contextFactory;
|
||||
|
||||
public UpdateTournamentCommand(TournamentsDbContextFactory contextFactory)
|
||||
public UpdateTournamentCommand(ApplicationDBContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public async Task Execute(Tournament tournament)
|
||||
{
|
||||
using (TournamentsDbContext context = _contextFactory.Create())
|
||||
using (ApplicationDbContext context = _contextFactory.Create())
|
||||
{
|
||||
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
|
||||
{
|
||||
[DbContext(typeof(TournamentsDbContext))]
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20220820005557_initial")]
|
||||
partial class initial
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Apollon.EntityFramework.Migrations
|
||||
{
|
||||
[DbContext(typeof(TournamentsDbContext))]
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20220828165744_initial1")]
|
||||
partial class initial1
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Apollon.EntityFramework.Migrations
|
||||
{
|
||||
[DbContext(typeof(TournamentsDbContext))]
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20221107194347_competition")]
|
||||
partial class competition
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Apollon.EntityFramework.Migrations
|
||||
{
|
||||
[DbContext(typeof(TournamentsDbContext))]
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20221110003817_logo")]
|
||||
partial class logo
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Apollon.EntityFramework.Migrations
|
||||
{
|
||||
[DbContext(typeof(TournamentsDbContext))]
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
partial class TournamentsDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
|
||||
@@ -12,16 +12,16 @@ namespace Apollon.EntityFramework.Queries
|
||||
{
|
||||
public class GetAllTournamentsQuery : IGetAllTournamentsQuery
|
||||
{
|
||||
private readonly TournamentsDbContextFactory _contextFactory;
|
||||
private readonly ApplicationDBContextFactory _contextFactory;
|
||||
|
||||
public GetAllTournamentsQuery(TournamentsDbContextFactory contextFactory)
|
||||
public GetAllTournamentsQuery(ApplicationDBContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Tournament>> Execute()
|
||||
{
|
||||
using (TournamentsDbContext context = _contextFactory.Create())
|
||||
using (ApplicationDbContext context = _contextFactory.Create())
|
||||
{
|
||||
IEnumerable<TournamentDto> tournamentsDtos = await context.Tournaments.ToListAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user