Files
Apollon/Apollon.EntityFramework/Commands/DeleteNameListCommand.cs
Natlinux ee8c687f5c Namelist
2022-11-13 18:10:38 +01:00

35 lines
927 B
C#

using Apollon.Domain.Commands;
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 DeleteNameListCommand : IDeleteNameListCommand
{
private readonly ApplicationDBContextFactory _contextFactory;
public DeleteNameListCommand(ApplicationDBContextFactory contextFactory)
{
_contextFactory = contextFactory;
}
public async Task Execute(Guid id)
{
using (ApplicationDbContext context = _contextFactory.Create())
{
NameListDto nameListDto = new NameListDto()
{
Id = id,
};
context.NameList.Remove(nameListDto);
await context.SaveChangesAsync();
}
}
}
}