Files
YouTubeViewers/YouTubeViewers.EntityFramework/Commands/DeleteYouTubeViewerCommand.cs
2022-08-22 15:56:12 +02:00

36 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTubeViewers.Domain.Commands;
using YouTubeViewers.EntityFramework.DTOs;
namespace YouTubeViewers.EntityFramework.Commands
{
public class DeleteYouTubeViewerCommand : IDeleteYouTubeViewerCommand
{
private readonly YouTubeViewersDbContextFactory _contextFactory;
public DeleteYouTubeViewerCommand(YouTubeViewersDbContextFactory contextFactory)
{
_contextFactory = contextFactory;
}
public async Task Execute(Guid id)
{
using (YouTubeViewersDbContext context = _contextFactory.Create())
{
await Task.Delay(5000);
YouTubeViewerDto youTubeViewerDto = new YouTubeViewerDto()
{
Id = id,
};
context.YouTubeViewers.Remove(youTubeViewerDto);
await context.SaveChangesAsync();
}
}
}
}