Removed todos and added User endpoint combined with register. Id changed to guid
This commit is contained in:
@@ -3,7 +3,7 @@ using Hutopy.Domain.Entities;
|
||||
|
||||
namespace Hutopy.Application.FutureCreators.Commands;
|
||||
|
||||
public abstract record CreateFutureCreatorCommand : IRequest<int>
|
||||
public record CreateFutureCreatorCommand : IRequest<Guid>
|
||||
{
|
||||
public required string FirstName { get; init; }
|
||||
public required string LastName { get; init; }
|
||||
@@ -15,9 +15,9 @@ public abstract record CreateFutureCreatorCommand : IRequest<int>
|
||||
|
||||
public class CreateFutureCreatorCommandHandler(
|
||||
IApplicationDbContext context)
|
||||
: IRequestHandler<CreateFutureCreatorCommand, int>
|
||||
: IRequestHandler<CreateFutureCreatorCommand, Guid>
|
||||
{
|
||||
public async Task<int> Handle(CreateFutureCreatorCommand request, CancellationToken cancellationToken)
|
||||
public async Task<Guid> Handle(CreateFutureCreatorCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = new FutureCreator
|
||||
{
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using Hutopy.Domain.Entities;
|
||||
|
||||
namespace Hutopy.Application.FutureCreators.Queries;
|
||||
|
||||
public class FutureCreatorListDto
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
|
||||
public required string FirstName { get; init; }
|
||||
|
||||
public required string LastName { get; init; }
|
||||
|
||||
private class Mapping : Profile
|
||||
{
|
||||
public Mapping()
|
||||
{
|
||||
CreateMap<FutureCreator, FutureCreatorListDto>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.Common.Mappings;
|
||||
using Hutopy.Application.Common.Models;
|
||||
|
||||
namespace Hutopy.Application.FutureCreators.Queries;
|
||||
|
||||
public record GetFutureCreatorListQuery : IRequest<PaginatedList<FutureCreatorListDto>>
|
||||
{
|
||||
public int PageNumber { get; init; } = 1;
|
||||
public int PageSize { get; init; } = 10;
|
||||
}
|
||||
|
||||
public class GetFutureCreatorListQueryHandler(
|
||||
IApplicationDbContext context,
|
||||
IMapper mapper)
|
||||
: IRequestHandler<GetFutureCreatorListQuery, PaginatedList<FutureCreatorListDto>>
|
||||
{
|
||||
public async Task<PaginatedList<FutureCreatorListDto>> Handle(GetFutureCreatorListQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
Console.WriteLine(request);
|
||||
return await context.FutureCreators
|
||||
.OrderBy(x => x.FirstName)
|
||||
.ProjectTo<FutureCreatorListDto>(mapper.ConfigurationProvider)
|
||||
.PaginatedListAsync(request.PageNumber, request.PageSize);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user