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

@@ -1,4 +1,6 @@
using Hutopy.Application.FutureCreators.Commands;
using Hutopy.Application.Common.Models;
using Hutopy.Application.FutureCreators.Commands;
using Hutopy.Application.FutureCreators.Queries;
namespace Hutopy.Web.Endpoints;
@@ -7,11 +9,17 @@ public class JoinUs : EndpointGroupBase
public override void Map(WebApplication app)
{
app.MapGroup(this)
.MapGet(GetFutureCreators)
.MapPost(CreateFutureCreator);
}
private static Task<int> CreateFutureCreator(ISender sender, CreateFutureCreatorCommand command)
private static Task<Guid> CreateFutureCreator(ISender sender, CreateFutureCreatorCommand command)
{
return sender.Send(command);
}
private static Task<PaginatedList<FutureCreatorListDto>> GetFutureCreators(ISender sender, [AsParameters] GetFutureCreatorListQuery query)
{
return sender.Send(query);
}
}

View File

@@ -1,52 +0,0 @@
using Hutopy.Application.Common.Models;
using Hutopy.Application.TodoItems.Commands.CreateTodoItem;
using Hutopy.Application.TodoItems.Commands.DeleteTodoItem;
using Hutopy.Application.TodoItems.Commands.UpdateTodoItem;
using Hutopy.Application.TodoItems.Commands.UpdateTodoItemDetail;
using Hutopy.Application.TodoItems.Queries.GetTodoItemsWithPagination;
namespace Hutopy.Web.Endpoints;
public class TodoItems : EndpointGroupBase
{
public override void Map(WebApplication app)
{
app.MapGroup(this)
.RequireAuthorization()
.MapGet(GetTodoItemsWithPagination)
.MapPost(CreateTodoItem)
.MapPut(UpdateTodoItem, "{id}")
.MapPut(UpdateTodoItemDetail, "UpdateDetail/{id}")
.MapDelete(DeleteTodoItem, "{id}");
}
private static Task<PaginatedList<TodoItemBriefDto>> GetTodoItemsWithPagination(ISender sender, [AsParameters] GetTodoItemsWithPaginationQuery query)
{
return sender.Send(query);
}
private static Task<int> CreateTodoItem(ISender sender, CreateTodoItemCommand command)
{
return sender.Send(command);
}
private static async Task<IResult> UpdateTodoItem(ISender sender, int id, UpdateTodoItemCommand command)
{
if (id != command.Id) return Results.BadRequest();
await sender.Send(command);
return Results.NoContent();
}
private static async Task<IResult> UpdateTodoItemDetail(ISender sender, int id, UpdateTodoItemDetailCommand command)
{
if (id != command.Id) return Results.BadRequest();
await sender.Send(command);
return Results.NoContent();
}
private static async Task<IResult> DeleteTodoItem(ISender sender, int id)
{
await sender.Send(new DeleteTodoItemCommand(id));
return Results.NoContent();
}
}

View File

@@ -1,42 +0,0 @@
using Hutopy.Application.TodoLists.Commands.CreateTodoList;
using Hutopy.Application.TodoLists.Commands.DeleteTodoList;
using Hutopy.Application.TodoLists.Commands.UpdateTodoList;
using Hutopy.Application.TodoLists.Queries.GetTodos;
namespace Hutopy.Web.Endpoints;
public class TodoLists : EndpointGroupBase
{
public override void Map(WebApplication app)
{
app.MapGroup(this)
.RequireAuthorization()
.MapGet(GetTodoLists)
.MapPost(CreateTodoList)
.MapPut(UpdateTodoList, "{id}")
.MapDelete(DeleteTodoList, "{id}");
}
private static Task<TodosVm> GetTodoLists(ISender sender)
{
return sender.Send(new GetTodosQuery());
}
private static Task<int> CreateTodoList(ISender sender, CreateTodoListCommand command)
{
return sender.Send(command);
}
private static async Task<IResult> UpdateTodoList(ISender sender, int id, UpdateTodoListCommand command)
{
if (id != command.Id) return Results.BadRequest();
await sender.Send(command);
return Results.NoContent();
}
private static async Task<IResult> DeleteTodoList(ISender sender, int id)
{
await sender.Send(new DeleteTodoListCommand(id));
return Results.NoContent();
}
}

View File

@@ -1,4 +1,6 @@
using Hutopy.Infrastructure.Identity;
using Hutopy.Application.Users.Commands;
using Hutopy.Domain.Interfaces;
using Hutopy.Infrastructure.Identity;
namespace Hutopy.Web.Endpoints;
@@ -7,6 +9,13 @@ public class Users : EndpointGroupBase
public override void Map(WebApplication app)
{
app.MapGroup(this)
.MapPost(CreateUser)
.MapIdentityApi<ApplicationUser>();
}
public async Task<Guid> CreateUser(ISender sender, CreateUserCommand command, IUserService userService)
{
await userService.CreateUserAsync(command.EmailAddress, command.UserName, command.Password);
return await sender.Send(command);
}
}