first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using MediatR;
|
||||
using SequenceAuth.Example.Domain;
|
||||
using SequenceAuth.Example.Infrastructure;
|
||||
|
||||
namespace SequenceAuth.Example.Features.Todos;
|
||||
|
||||
public record CreateTodoCommand(Guid UserId, string Title) : IRequest<TodoItem>;
|
||||
|
||||
public class CreateTodoCommandHandler(AppDbContext dbContext) : IRequestHandler<CreateTodoCommand, TodoItem>
|
||||
{
|
||||
public async Task<TodoItem> Handle(CreateTodoCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var todo = new TodoItem(Guid.NewGuid(), request.UserId, request.Title, TodoStatus.Pending);
|
||||
dbContext.Todos.Add(todo);
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
return todo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user