Started FuturCreator
This commit is contained in:
@@ -8,5 +8,7 @@ public interface IApplicationDbContext
|
||||
|
||||
DbSet<TodoItem> TodoItems { get; }
|
||||
|
||||
DbSet<FuturCreator> FuturCreator { get; }
|
||||
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
43
src/Application/FuturCreator/Commands/CreateFuturCreator.cs
Normal file
43
src/Application/FuturCreator/Commands/CreateFuturCreator.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
|
||||
namespace Hutopy.Application.TodoItems.Commands.CreateFuturCreator;
|
||||
|
||||
public record CreateFuturCreatorCommand : IRequest<int>
|
||||
{
|
||||
public required string FirstName { get; init; }
|
||||
public required string LastName { get; init; }
|
||||
public required string EmailAddress { get; init; }
|
||||
public required string PhoneNumber { get; init; }
|
||||
public required string SocialNetworkAccount { get; init; }
|
||||
public required string ReasonToJoin { get; init; }
|
||||
}
|
||||
|
||||
public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFuturCreatorCommand, int>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
|
||||
public CreateFuturCreatorCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<int> Handle(CreateFuturCreatorCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = new FuturCreator()
|
||||
{
|
||||
FirstName = request.FirstName,
|
||||
LastName = request.LastName,
|
||||
EmailAddress = request.EmailAddress,
|
||||
PhoneNumber = request.PhoneNumber,
|
||||
SocialNetworkAccount = request.SocialNetworkAccount,
|
||||
ReasonToJoin = request.ReasonToJoin,
|
||||
};
|
||||
|
||||
_context.FuturCreator.Add(entity);
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return entity.Id;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user