From d607c9be23ebafe8126cdf39046aa9a9f9045878 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Tue, 31 Dec 2024 16:36:50 +0100 Subject: [PATCH] chore: resolve miscellaneous issues in `Reminders` module --- .../Endpoints/Reminders/CreateReminder.cs | 3 +++ .../Endpoints/Reminders/GetReminderById.cs | 26 +++++++++---------- .../Endpoints/Reminders/ListReminders.cs | 20 +++++++------- .../CreateReminder/CreateReminderCommand.cs | 5 ++-- .../GetReminderById/GetReminderByIdQuery.cs | 5 +++- .../ListReminders/ListRemindersQuery.cs | 2 ++ .../Reminders.Application/GlobalUsing.cs | 9 ++++--- 7 files changed, 40 insertions(+), 30 deletions(-) diff --git a/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/CreateReminder.cs b/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/CreateReminder.cs index aae3a5a..c9ffb7b 100644 --- a/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/CreateReminder.cs +++ b/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/CreateReminder.cs @@ -1,6 +1,8 @@ using BuildingBlocks.Domain.ValueObjects.Ids; using Reminders.Application.Entities.Reminders.Commands.CreateReminder; +// ReSharper disable ClassNeverInstantiated.Global + namespace Reminders.Api.Endpoints.Reminders; public class CreateReminder : ICarterModule @@ -23,6 +25,7 @@ public void AddRoutes(IEndpointRouteBuilder app) } } +// ReSharper disable once NotAccessedPositionalProperty.Global public record CreateReminderRequest(ReminderDto Reminder); public record CreateReminderResponse(ReminderId Id); diff --git a/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/GetReminderById.cs b/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/GetReminderById.cs index a2f25ae..5fbb74f 100644 --- a/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/GetReminderById.cs +++ b/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/GetReminderById.cs @@ -1,5 +1,5 @@ -using Reminders.Application.Entities.Reminders.Queries.GetReminderById; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; +using Reminders.Application.Entities.Reminders.Queries.GetReminderById; namespace Reminders.Api.Endpoints.Reminders; @@ -9,18 +9,18 @@ public class GetReminderById : ICarterModule public void AddRoutes(IEndpointRouteBuilder app) { app.MapGet("/Reminders/{reminderId}", async (string reminderId, ISender sender) => - { - var result = await sender.Send(new GetReminderByIdQuery(reminderId)); - var response = result.Adapt(); + { + var result = await sender.Send(new GetReminderByIdQuery(reminderId)); + var response = result.Adapt(); - return Results.Ok(response); - }) - .WithName("GetReminderById") - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .ProducesProblem(StatusCodes.Status404NotFound) - .WithSummary("Get Reminder by Id") - .WithDescription("Get Reminder by Id"); + return Results.Ok(response); + }) + .WithName("GetReminderById") + .Produces() + .ProducesProblem(StatusCodes.Status400BadRequest) + .ProducesProblem(StatusCodes.Status404NotFound) + .WithSummary("Get Reminder by Id") + .WithDescription("Get Reminder by Id"); } } diff --git a/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/ListReminders.cs b/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/ListReminders.cs index 592cbb3..42c2d21 100644 --- a/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/ListReminders.cs +++ b/Backend/src/Modules/Reminders/Reminders.Api/Endpoints/Reminders/ListReminders.cs @@ -8,17 +8,17 @@ public class ListReminders : ICarterModule public void AddRoutes(IEndpointRouteBuilder app) { app.MapGet("/Reminders", async ([AsParameters] PaginationRequest query, ISender sender) => - { - var result = await sender.Send(new ListRemindersQuery(query)); - var response = result.Adapt(); + { + var result = await sender.Send(new ListRemindersQuery(query)); + var response = result.Adapt(); - return Results.Ok(response); - }) - .WithName("ListReminders") - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("List Reminders") - .WithDescription("List Reminders"); + return Results.Ok(response); + }) + .WithName("ListReminders") + .Produces() + .ProducesProblem(StatusCodes.Status400BadRequest) + .WithSummary("List Reminders") + .WithDescription("List Reminders"); } } diff --git a/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Commands/CreateReminder/CreateReminderCommand.cs b/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Commands/CreateReminder/CreateReminderCommand.cs index 37c2c96..306a68f 100644 --- a/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Commands/CreateReminder/CreateReminderCommand.cs +++ b/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Commands/CreateReminder/CreateReminderCommand.cs @@ -1,10 +1,11 @@ -using FluentValidation; -using Reminders.Application.Entities.Reminders.Dtos; +using Reminders.Application.Entities.Reminders.Dtos; namespace Reminders.Application.Entities.Reminders.Commands.CreateReminder; +// ReSharper disable once ClassNeverInstantiated.Global public record CreateReminderCommand(ReminderDto Reminder) : ICommand; +// ReSharper disable once NotAccessedPositionalProperty.Global public record CreateReminderResult(ReminderId Id); public class CreateReminderCommandValidator : AbstractValidator diff --git a/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Queries/GetReminderById/GetReminderByIdQuery.cs b/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Queries/GetReminderById/GetReminderByIdQuery.cs index a954f10..8be8cc8 100644 --- a/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Queries/GetReminderById/GetReminderByIdQuery.cs +++ b/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Queries/GetReminderById/GetReminderByIdQuery.cs @@ -1,7 +1,10 @@ -using Reminders.Application.Entities.Reminders.Dtos; +// ReSharper disable ClassNeverInstantiated.Global + +using Reminders.Application.Entities.Reminders.Dtos; namespace Reminders.Application.Entities.Reminders.Queries.GetReminderById; public record GetReminderByIdQuery(string Id) : IQuery; +// ReSharper disable once NotAccessedPositionalProperty.Global public record GetReminderByIdResult(ReminderDto ReminderDto); diff --git a/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Queries/ListReminders/ListRemindersQuery.cs b/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Queries/ListReminders/ListRemindersQuery.cs index 0c7974f..23f53cb 100644 --- a/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Queries/ListReminders/ListRemindersQuery.cs +++ b/Backend/src/Modules/Reminders/Reminders.Application/Entities/Reminders/Queries/ListReminders/ListRemindersQuery.cs @@ -1,6 +1,8 @@ using BuildingBlocks.Application.Pagination; using Reminders.Application.Entities.Reminders.Dtos; +// ReSharper disable ClassNeverInstantiated.Global + namespace Reminders.Application.Entities.Reminders.Queries.ListReminders; public record ListRemindersQuery(PaginationRequest PaginationRequest) : IQuery; diff --git a/Backend/src/Modules/Reminders/Reminders.Application/GlobalUsing.cs b/Backend/src/Modules/Reminders/Reminders.Application/GlobalUsing.cs index a0b1a30..b2224e5 100644 --- a/Backend/src/Modules/Reminders/Reminders.Application/GlobalUsing.cs +++ b/Backend/src/Modules/Reminders/Reminders.Application/GlobalUsing.cs @@ -1,6 +1,7 @@ -global using Microsoft.EntityFrameworkCore; +global using FluentValidation; +global using Microsoft.EntityFrameworkCore; global using BuildingBlocks.Application.Cqrs; -global using Reminders.Domain.Models; -global using Reminders.Application.Data; -global using BuildingBlocks.Domain.ValueObjects.Ids; global using BuildingBlocks.Application.Exceptions; +global using BuildingBlocks.Domain.ValueObjects.Ids; +global using Reminders.Application.Data; +global using Reminders.Domain.Models;