ready for database
This commit is contained in:
35
Apollon.EntityFramework/Commands/DeleteTournamentCommand.cs
Normal file
35
Apollon.EntityFramework/Commands/DeleteTournamentCommand.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Apollon.Domain.Commands;
|
||||
using Apollon.Domain.Models;
|
||||
using Apollon.EntityFramework.DTOs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Apollon.EntityFramework.Commands
|
||||
{
|
||||
public class DeleteTournamentCommand : IDeleteTournamentCommand
|
||||
{
|
||||
private readonly TournamentsDBContextFactory _contextFactory;
|
||||
|
||||
public DeleteTournamentCommand(TournamentsDBContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public async Task Execute(Guid id)
|
||||
{
|
||||
using (TournamentsDBContext context = _contextFactory.Create())
|
||||
{
|
||||
TournamentDto tournamentDto = new TournamentDto()
|
||||
{
|
||||
Id = id,
|
||||
};
|
||||
|
||||
context.Tournaments.Remove(tournamentDto);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user