Files
mws.backend.dotnet/mws.application/Tasks/Commands/DeleteTask.cs
T

17 lines
500 B
C#
Raw Normal View History

using MediatR;
using Mws.Application.Common;
namespace Mws.Application.Tasks;
public record DeleteTaskCommand(Guid UserId, Guid TaskId) : IRequest;
public class DeleteTaskHandler(IUnitOfWork uow) : IRequestHandler<DeleteTaskCommand>
{
public async Task Handle(DeleteTaskCommand command, CancellationToken ct)
{
var task = await TaskAccess.GetTaskForUserAsync(uow, command.UserId, command.TaskId, ct);
uow.Tasks.Remove(task);
await uow.SaveChangesAsync(ct);
}
}