Removed todos and added User endpoint combined with register. Id changed to guid

This commit is contained in:
Dominic Villemure
2024-04-03 23:57:01 -04:00
parent df8b42bdf1
commit 1f795c53bb
67 changed files with 1750 additions and 1895 deletions

View File

@@ -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
{

View File

@@ -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>();
}
}
}

View File

@@ -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);
}
}