From 0dd57b229853b2b868e4c844b6aeba5f323ef4f3 Mon Sep 17 00:00:00 2001 From: Tom Brereton Date: Fri, 6 Sep 2024 12:56:26 +1000 Subject: [PATCH] remove id on entity inherited class and tidy code --- src/Web.Api/Domain/Accounts/UserAccount.cs | 5 ++--- src/Web.Api/Domain/Calendars/Calendar.cs | 1 - src/Web.Api/Features/Accounts/CreateAccount.cs | 8 +++++--- src/Web.Api/Features/Accounts/GetAccount.cs | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Web.Api/Domain/Accounts/UserAccount.cs b/src/Web.Api/Domain/Accounts/UserAccount.cs index 40a8af6..91c8efd 100644 --- a/src/Web.Api/Domain/Accounts/UserAccount.cs +++ b/src/Web.Api/Domain/Accounts/UserAccount.cs @@ -17,9 +17,8 @@ private UserAccount() { } - public Guid Id { get; private set; } public string FullName { get; private set; } - public List Calendars { get; private set; } = new List(); + public List Calendars { get; private set; } = []; public bool IsActive { get; private set; } public bool IsDeleted { get; private set; } @@ -31,4 +30,4 @@ public static UserAccount Create(string fullName) return userAccount; } -} +} \ No newline at end of file diff --git a/src/Web.Api/Domain/Calendars/Calendar.cs b/src/Web.Api/Domain/Calendars/Calendar.cs index a0174e2..4aceb5e 100644 --- a/src/Web.Api/Domain/Calendars/Calendar.cs +++ b/src/Web.Api/Domain/Calendars/Calendar.cs @@ -15,7 +15,6 @@ private Calendar() { } - public Guid Id { get; private set; } public string Name { get; private set; } public Guid UserAccountId { get; private set; } public UserAccount UserAccount { get; private set; } = null!; diff --git a/src/Web.Api/Features/Accounts/CreateAccount.cs b/src/Web.Api/Features/Accounts/CreateAccount.cs index 88262d2..f6d09bc 100644 --- a/src/Web.Api/Features/Accounts/CreateAccount.cs +++ b/src/Web.Api/Features/Accounts/CreateAccount.cs @@ -12,10 +12,12 @@ public class CreateAccountEndpoint : ICarterModule { public void AddRoutes(IEndpointRouteBuilder app) { - app.MapPost("api/accounts", async (CreateAccount.Command request, ISender sender, CancellationToken cancellationToken) => + app.MapPost("api/accounts", async ( + CreateAccount.Command request, + ISender sender, + CancellationToken cancellationToken) => { var result = await sender.Send(request, cancellationToken); - if (result.IsFailure) { return Results.BadRequest(result.Error); @@ -67,4 +69,4 @@ public async Task> Handle(Command request, Cancell return new CreateAccountResponse(userAccount.Id, userAccount.FullName); } } -} +} \ No newline at end of file diff --git a/src/Web.Api/Features/Accounts/GetAccount.cs b/src/Web.Api/Features/Accounts/GetAccount.cs index 67d4993..3b4f3dd 100644 --- a/src/Web.Api/Features/Accounts/GetAccount.cs +++ b/src/Web.Api/Features/Accounts/GetAccount.cs @@ -53,5 +53,4 @@ public async Task> Handle(Query request, Cancellation return new GetAccountResponse(account.Id, account.FullName); } } -} - +} \ No newline at end of file