Style: C# 12 Primary constructor
This commit is contained in:
@@ -3,7 +3,7 @@ using Hutopy.Domain.Entities;
|
||||
|
||||
namespace Hutopy.Application.FutureCreators.Commands;
|
||||
|
||||
public record CreateFutureCreatorCommand : IRequest<int>
|
||||
public abstract record CreateFutureCreatorCommand : IRequest<int>
|
||||
{
|
||||
public required string FirstName { get; init; }
|
||||
public required string LastName { get; init; }
|
||||
@@ -13,16 +13,10 @@ public record CreateFutureCreatorCommand : IRequest<int>
|
||||
public required string ReasonToJoin { get; init; }
|
||||
}
|
||||
|
||||
public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFutureCreatorCommand, int>
|
||||
public class CreateFutureCreatorCommandHandler(
|
||||
IApplicationDbContext context)
|
||||
: IRequestHandler<CreateFutureCreatorCommand, int>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
|
||||
public CreateFuturCreatorCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<int> Handle(CreateFutureCreatorCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = new FutureCreator
|
||||
@@ -35,9 +29,9 @@ public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFutureCrea
|
||||
ReasonToJoin = request.ReasonToJoin,
|
||||
};
|
||||
|
||||
_context.FutureCreators.Add(entity);
|
||||
context.FutureCreators.Add(entity);
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
await context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return entity.Id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user