diff --git a/StudioManager.API/Controllers/V1/ReservationsController.cs b/StudioManager.API/Controllers/V1/ReservationsController.cs index 717598b..b8ace57 100644 --- a/StudioManager.API/Controllers/V1/ReservationsController.cs +++ b/StudioManager.API/Controllers/V1/ReservationsController.cs @@ -5,10 +5,10 @@ using StudioManager.API.Base; using StudioManager.API.Contracts.Pagination; using StudioManager.API.Contracts.Reservations; -using StudioManager.Application.Reservations.BetById; using StudioManager.Application.Reservations.Create; using StudioManager.Application.Reservations.Delete; using StudioManager.Application.Reservations.GetAll; +using StudioManager.Application.Reservations.GetById; using StudioManager.Application.Reservations.Update; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Filters; diff --git a/StudioManager.Application.Tests/Reservations/GetReservationByIdQueryHandlerTests/Handle.cs b/StudioManager.Application.Tests/Reservations/GetReservationByIdQueryHandlerTests/Handle.cs index 245ecf9..64100a7 100644 --- a/StudioManager.Application.Tests/Reservations/GetReservationByIdQueryHandlerTests/Handle.cs +++ b/StudioManager.Application.Tests/Reservations/GetReservationByIdQueryHandlerTests/Handle.cs @@ -1,7 +1,7 @@ using FluentAssertions; using NUnit.Framework; using StudioManager.API.Contracts.Reservations; -using StudioManager.Application.Reservations.BetById; +using StudioManager.Application.Reservations.GetById; using StudioManager.Application.Tests.Reservations.Common; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Entities; diff --git a/StudioManager.Application.Tests/Reservations/GetReservationByIdQueryHandlerTests/Validator.cs b/StudioManager.Application.Tests/Reservations/GetReservationByIdQueryHandlerTests/Validator.cs index fde09cf..e66e5a1 100644 --- a/StudioManager.Application.Tests/Reservations/GetReservationByIdQueryHandlerTests/Validator.cs +++ b/StudioManager.Application.Tests/Reservations/GetReservationByIdQueryHandlerTests/Validator.cs @@ -1,6 +1,6 @@ using FluentAssertions; using NUnit.Framework; -using StudioManager.Application.Reservations.BetById; +using StudioManager.Application.Reservations.GetById; namespace StudioManager.Application.Tests.Reservations.GetReservationByIdQueryHandlerTests; diff --git a/StudioManager.Application/EquipmentTypes/Create/CreateEquipmentTypeCommand.cs b/StudioManager.Application/EquipmentTypes/Create/CreateEquipmentTypeCommand.cs index 8ae134d..e135ef5 100644 --- a/StudioManager.Application/EquipmentTypes/Create/CreateEquipmentTypeCommand.cs +++ b/StudioManager.Application/EquipmentTypes/Create/CreateEquipmentTypeCommand.cs @@ -1,7 +1,6 @@ -using MediatR; -using StudioManager.API.Contracts.EquipmentTypes; +using StudioManager.API.Contracts.EquipmentTypes; using StudioManager.Domain.Common.Results; namespace StudioManager.Application.EquipmentTypes.Create; -public sealed record CreateEquipmentTypeCommand(EquipmentTypeWriteDto EquipmentType) : IRequest; +public sealed record CreateEquipmentTypeCommand(EquipmentTypeWriteDto EquipmentType) : ICommand; diff --git a/StudioManager.Application/EquipmentTypes/Create/CreateEquipmentTypeCommandHandler.cs b/StudioManager.Application/EquipmentTypes/Create/CreateEquipmentTypeCommandHandler.cs index 782a88a..4843657 100644 --- a/StudioManager.Application/EquipmentTypes/Create/CreateEquipmentTypeCommandHandler.cs +++ b/StudioManager.Application/EquipmentTypes/Create/CreateEquipmentTypeCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.DbContextExtensions; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Entities; @@ -11,7 +10,7 @@ namespace StudioManager.Application.EquipmentTypes.Create; public sealed class CreateEquipmentTypeCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(CreateEquipmentTypeCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/EquipmentTypes/Delete/DeleteEquipmentTypeCommand.cs b/StudioManager.Application/EquipmentTypes/Delete/DeleteEquipmentTypeCommand.cs index c103325..7e3a476 100644 --- a/StudioManager.Application/EquipmentTypes/Delete/DeleteEquipmentTypeCommand.cs +++ b/StudioManager.Application/EquipmentTypes/Delete/DeleteEquipmentTypeCommand.cs @@ -1,6 +1,5 @@ -using MediatR; -using StudioManager.Domain.Common.Results; +using StudioManager.Domain.Common.Results; namespace StudioManager.Application.EquipmentTypes.Delete; -public sealed record DeleteEquipmentTypeCommand(Guid Id) : IRequest; +public sealed record DeleteEquipmentTypeCommand(Guid Id) : ICommand; diff --git a/StudioManager.Application/EquipmentTypes/Delete/DeleteEquipmentTypeCommandHandler.cs b/StudioManager.Application/EquipmentTypes/Delete/DeleteEquipmentTypeCommandHandler.cs index 5a55dde..d043409 100644 --- a/StudioManager.Application/EquipmentTypes/Delete/DeleteEquipmentTypeCommandHandler.cs +++ b/StudioManager.Application/EquipmentTypes/Delete/DeleteEquipmentTypeCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.DbContextExtensions; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Entities; @@ -10,7 +9,7 @@ namespace StudioManager.Application.EquipmentTypes.Delete; public sealed class DeleteEquipmentTypeCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(DeleteEquipmentTypeCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/EquipmentTypes/GetAll/GetEquipmentTypesQuery.cs b/StudioManager.Application/EquipmentTypes/GetAll/GetEquipmentTypesQuery.cs index 8bde8ef..3b45468 100644 --- a/StudioManager.Application/EquipmentTypes/GetAll/GetEquipmentTypesQuery.cs +++ b/StudioManager.Application/EquipmentTypes/GetAll/GetEquipmentTypesQuery.cs @@ -1,11 +1,10 @@ -using MediatR; -using StudioManager.API.Contracts.EquipmentTypes; +using StudioManager.API.Contracts.EquipmentTypes; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Filters; namespace StudioManager.Application.EquipmentTypes.GetAll; -public sealed class GetEquipmentTypesQuery : IRequest>> +public sealed class GetEquipmentTypesQuery : IQuery> { public required EquipmentTypeFilter Filter { get; init; } } diff --git a/StudioManager.Application/EquipmentTypes/GetAll/GetEquipmentTypesQueryHandler.cs b/StudioManager.Application/EquipmentTypes/GetAll/GetEquipmentTypesQueryHandler.cs index f9d54e2..c9a8ab5 100644 --- a/StudioManager.Application/EquipmentTypes/GetAll/GetEquipmentTypesQueryHandler.cs +++ b/StudioManager.Application/EquipmentTypes/GetAll/GetEquipmentTypesQueryHandler.cs @@ -1,6 +1,5 @@ using AutoMapper; using AutoMapper.QueryableExtensions; -using MediatR; using Microsoft.EntityFrameworkCore; using StudioManager.API.Contracts.EquipmentTypes; using StudioManager.Domain.Common.Results; @@ -11,7 +10,7 @@ namespace StudioManager.Application.EquipmentTypes.GetAll; public sealed class GetEquipmentTypesQueryHandler( IDbContextFactory dbContextFactory, IMapper mapper) - : IRequestHandler>> + : IQueryHandler> { public async Task>> Handle( GetEquipmentTypesQuery request, diff --git a/StudioManager.Application/EquipmentTypes/GetById/GetEquipmentTypeByIdQuery.cs b/StudioManager.Application/EquipmentTypes/GetById/GetEquipmentTypeByIdQuery.cs index ff1ff04..c5f275f 100644 --- a/StudioManager.Application/EquipmentTypes/GetById/GetEquipmentTypeByIdQuery.cs +++ b/StudioManager.Application/EquipmentTypes/GetById/GetEquipmentTypeByIdQuery.cs @@ -1,10 +1,9 @@ -using MediatR; -using StudioManager.API.Contracts.EquipmentTypes; +using StudioManager.API.Contracts.EquipmentTypes; using StudioManager.Domain.Common.Results; namespace StudioManager.Application.EquipmentTypes.GetById; -public sealed record GetEquipmentTypeByIdQuery(Guid Id) : IRequest> +public sealed record GetEquipmentTypeByIdQuery(Guid Id) : IQuery { public Guid Id { get; } = Id; } diff --git a/StudioManager.Application/EquipmentTypes/GetById/GetEquipmentTypeByIdQueryHandler.cs b/StudioManager.Application/EquipmentTypes/GetById/GetEquipmentTypeByIdQueryHandler.cs index 8d9a8ee..2e14722 100644 --- a/StudioManager.Application/EquipmentTypes/GetById/GetEquipmentTypeByIdQueryHandler.cs +++ b/StudioManager.Application/EquipmentTypes/GetById/GetEquipmentTypeByIdQueryHandler.cs @@ -1,6 +1,5 @@ using AutoMapper; using AutoMapper.QueryableExtensions; -using MediatR; using Microsoft.EntityFrameworkCore; using StudioManager.API.Contracts.EquipmentTypes; using StudioManager.Domain.Common.Results; @@ -12,9 +11,10 @@ namespace StudioManager.Application.EquipmentTypes.GetById; public sealed class GetEquipmentTypeByIdQueryHandler( IDbContextFactory dbContextFactory, IMapper mapper) - : IRequestHandler> + : IQueryHandler { - public async Task> Handle(GetEquipmentTypeByIdQuery request, CancellationToken cancellationToken) + public async Task> Handle(GetEquipmentTypeByIdQuery request, + CancellationToken cancellationToken) { await using var dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); diff --git a/StudioManager.Application/EquipmentTypes/Update/UpdateEquipmentTypeCommand.cs b/StudioManager.Application/EquipmentTypes/Update/UpdateEquipmentTypeCommand.cs index 4a4e4b7..d1e449f 100644 --- a/StudioManager.Application/EquipmentTypes/Update/UpdateEquipmentTypeCommand.cs +++ b/StudioManager.Application/EquipmentTypes/Update/UpdateEquipmentTypeCommand.cs @@ -1,7 +1,6 @@ -using MediatR; -using StudioManager.API.Contracts.EquipmentTypes; +using StudioManager.API.Contracts.EquipmentTypes; using StudioManager.Domain.Common.Results; namespace StudioManager.Application.EquipmentTypes.Update; -public sealed record UpdateEquipmentTypeCommand(Guid Id, EquipmentTypeWriteDto EquipmentType) : IRequest; +public sealed record UpdateEquipmentTypeCommand(Guid Id, EquipmentTypeWriteDto EquipmentType) : ICommand; diff --git a/StudioManager.Application/EquipmentTypes/Update/UpdateEquipmentTypeCommandHandler.cs b/StudioManager.Application/EquipmentTypes/Update/UpdateEquipmentTypeCommandHandler.cs index 8968eb4..ce04dd6 100644 --- a/StudioManager.Application/EquipmentTypes/Update/UpdateEquipmentTypeCommandHandler.cs +++ b/StudioManager.Application/EquipmentTypes/Update/UpdateEquipmentTypeCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.DbContextExtensions; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Entities; @@ -11,7 +10,7 @@ namespace StudioManager.Application.EquipmentTypes.Update; public sealed class UpdateEquipmentTypeCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(UpdateEquipmentTypeCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/Equipments/Create/CreateEquipmentCommand.cs b/StudioManager.Application/Equipments/Create/CreateEquipmentCommand.cs index 258817f..3f1c52f 100644 --- a/StudioManager.Application/Equipments/Create/CreateEquipmentCommand.cs +++ b/StudioManager.Application/Equipments/Create/CreateEquipmentCommand.cs @@ -1,7 +1,6 @@ -using MediatR; -using StudioManager.API.Contracts.Equipments; +using StudioManager.API.Contracts.Equipments; using StudioManager.Domain.Common.Results; namespace StudioManager.Application.Equipments.Create; -public sealed record CreateEquipmentCommand(EquipmentWriteDto Equipment) : IRequest; +public sealed record CreateEquipmentCommand(EquipmentWriteDto Equipment) : ICommand; diff --git a/StudioManager.Application/Equipments/Create/CreateEquipmentCommandHandler.cs b/StudioManager.Application/Equipments/Create/CreateEquipmentCommandHandler.cs index 50e0ca7..f1353dd 100644 --- a/StudioManager.Application/Equipments/Create/CreateEquipmentCommandHandler.cs +++ b/StudioManager.Application/Equipments/Create/CreateEquipmentCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.Equipments.Common; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Entities; @@ -9,7 +8,7 @@ namespace StudioManager.Application.Equipments.Create; public sealed class CreateEquipmentCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(CreateEquipmentCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/Equipments/Delete/DeleteEquipmentCommand.cs b/StudioManager.Application/Equipments/Delete/DeleteEquipmentCommand.cs index 4c55a5f..f82dd4c 100644 --- a/StudioManager.Application/Equipments/Delete/DeleteEquipmentCommand.cs +++ b/StudioManager.Application/Equipments/Delete/DeleteEquipmentCommand.cs @@ -1,6 +1,5 @@ -using MediatR; -using StudioManager.Domain.Common.Results; +using StudioManager.Domain.Common.Results; namespace StudioManager.Application.Equipments.Delete; -public sealed record DeleteEquipmentCommand(Guid Id) : IRequest; +public sealed record DeleteEquipmentCommand(Guid Id) : ICommand; diff --git a/StudioManager.Application/Equipments/Delete/DeleteEquipmentCommandHandler.cs b/StudioManager.Application/Equipments/Delete/DeleteEquipmentCommandHandler.cs index 110bae2..f89eaa9 100644 --- a/StudioManager.Application/Equipments/Delete/DeleteEquipmentCommandHandler.cs +++ b/StudioManager.Application/Equipments/Delete/DeleteEquipmentCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.DbContextExtensions; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Entities; @@ -11,7 +10,7 @@ namespace StudioManager.Application.Equipments.Delete; public sealed class DeleteEquipmentCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(DeleteEquipmentCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/Equipments/GetAll/GetAllEquipmentsQuery.cs b/StudioManager.Application/Equipments/GetAll/GetAllEquipmentsQuery.cs index 201564f..cec6851 100644 --- a/StudioManager.Application/Equipments/GetAll/GetAllEquipmentsQuery.cs +++ b/StudioManager.Application/Equipments/GetAll/GetAllEquipmentsQuery.cs @@ -1,5 +1,4 @@ -using MediatR; -using StudioManager.API.Contracts.Equipments; +using StudioManager.API.Contracts.Equipments; using StudioManager.API.Contracts.Pagination; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Filters; @@ -9,7 +8,7 @@ namespace StudioManager.Application.Equipments.GetAll; public sealed class GetAllEquipmentsQuery( EquipmentFilter filter, PaginationDto pagination) - : IRequest>> + : IQuery> { public EquipmentFilter Filter { get; } = filter; public PaginationDto Pagination { get; } = pagination; diff --git a/StudioManager.Application/Equipments/GetAll/GetAllEquipmentsQueryHandler.cs b/StudioManager.Application/Equipments/GetAll/GetAllEquipmentsQueryHandler.cs index 8f88c05..7c73358 100644 --- a/StudioManager.Application/Equipments/GetAll/GetAllEquipmentsQueryHandler.cs +++ b/StudioManager.Application/Equipments/GetAll/GetAllEquipmentsQueryHandler.cs @@ -1,6 +1,5 @@ using AutoMapper; using AutoMapper.QueryableExtensions; -using MediatR; using Microsoft.EntityFrameworkCore; using StudioManager.API.Contracts.Equipments; using StudioManager.API.Contracts.Pagination; @@ -13,7 +12,7 @@ namespace StudioManager.Application.Equipments.GetAll; public sealed class GetAllEquipmentsQueryHandler( IMapper mapper, IDbContextFactory dbContextFactory) - : IRequestHandler>> + : IQueryHandler> { public async Task>> Handle(GetAllEquipmentsQuery request, CancellationToken cancellationToken) diff --git a/StudioManager.Application/Equipments/GetById/GetEquipmentByIdQuery.cs b/StudioManager.Application/Equipments/GetById/GetEquipmentByIdQuery.cs index 4aff8c4..8920f2f 100644 --- a/StudioManager.Application/Equipments/GetById/GetEquipmentByIdQuery.cs +++ b/StudioManager.Application/Equipments/GetById/GetEquipmentByIdQuery.cs @@ -1,10 +1,9 @@ -using MediatR; -using StudioManager.API.Contracts.Equipments; +using StudioManager.API.Contracts.Equipments; using StudioManager.Domain.Common.Results; namespace StudioManager.Application.Equipments.GetById; -public sealed record GetEquipmentByIdQuery(Guid Id) : IRequest> +public sealed record GetEquipmentByIdQuery(Guid Id) : IQuery { public Guid Id { get; } = Id; } diff --git a/StudioManager.Application/Equipments/GetById/GetEquipmentByIdQueryHandler.cs b/StudioManager.Application/Equipments/GetById/GetEquipmentByIdQueryHandler.cs index 96fb787..c9ba255 100644 --- a/StudioManager.Application/Equipments/GetById/GetEquipmentByIdQueryHandler.cs +++ b/StudioManager.Application/Equipments/GetById/GetEquipmentByIdQueryHandler.cs @@ -1,6 +1,5 @@ using AutoMapper; using AutoMapper.QueryableExtensions; -using MediatR; using Microsoft.EntityFrameworkCore; using StudioManager.API.Contracts.Equipments; using StudioManager.Domain.Common.Results; @@ -12,9 +11,10 @@ namespace StudioManager.Application.Equipments.GetById; public sealed class GetEquipmentByIdQueryHandler( IDbContextFactory dbContextFactory, IMapper mapper) - : IRequestHandler> + : IQueryHandler { - public async Task> Handle(GetEquipmentByIdQuery request, CancellationToken cancellationToken) + public async Task> Handle(GetEquipmentByIdQuery request, + CancellationToken cancellationToken) { await using var dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); diff --git a/StudioManager.Application/Equipments/Update/UpdateEquipmentCommand.cs b/StudioManager.Application/Equipments/Update/UpdateEquipmentCommand.cs index 9eacc0c..0778613 100644 --- a/StudioManager.Application/Equipments/Update/UpdateEquipmentCommand.cs +++ b/StudioManager.Application/Equipments/Update/UpdateEquipmentCommand.cs @@ -1,7 +1,6 @@ -using MediatR; -using StudioManager.API.Contracts.Equipments; +using StudioManager.API.Contracts.Equipments; using StudioManager.Domain.Common.Results; namespace StudioManager.Application.Equipments.Update; -public sealed record UpdateEquipmentCommand(Guid Id, EquipmentWriteDto Equipment) : IRequest; +public sealed record UpdateEquipmentCommand(Guid Id, EquipmentWriteDto Equipment) : ICommand; diff --git a/StudioManager.Application/Equipments/Update/UpdateEquipmentCommandHandler.cs b/StudioManager.Application/Equipments/Update/UpdateEquipmentCommandHandler.cs index 0d21670..33b28a2 100644 --- a/StudioManager.Application/Equipments/Update/UpdateEquipmentCommandHandler.cs +++ b/StudioManager.Application/Equipments/Update/UpdateEquipmentCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.DbContextExtensions; using StudioManager.Application.Equipments.Common; using StudioManager.Domain.Common.Results; @@ -10,7 +9,7 @@ namespace StudioManager.Application.Equipments.Update; public sealed class UpdateEquipmentCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(UpdateEquipmentCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/Reservations/BetById/GetReservationByIdQuery.cs b/StudioManager.Application/Reservations/BetById/GetReservationByIdQuery.cs deleted file mode 100644 index 4cc5c6e..0000000 --- a/StudioManager.Application/Reservations/BetById/GetReservationByIdQuery.cs +++ /dev/null @@ -1,10 +0,0 @@ -using MediatR; -using StudioManager.API.Contracts.Reservations; -using StudioManager.Domain.Common.Results; - -namespace StudioManager.Application.Reservations.BetById; - -public sealed record GetReservationByIdQuery(Guid Id) : IRequest> -{ - public Guid Id { get; } = Id; -} diff --git a/StudioManager.Application/Reservations/Create/CreateReservationCommand.cs b/StudioManager.Application/Reservations/Create/CreateReservationCommand.cs index ccef50a..0ce7389 100644 --- a/StudioManager.Application/Reservations/Create/CreateReservationCommand.cs +++ b/StudioManager.Application/Reservations/Create/CreateReservationCommand.cs @@ -1,7 +1,6 @@ -using MediatR; -using StudioManager.API.Contracts.Reservations; +using StudioManager.API.Contracts.Reservations; using StudioManager.Domain.Common.Results; namespace StudioManager.Application.Reservations.Create; -public sealed record CreateReservationCommand(ReservationWriteDto Reservation) : IRequest; +public sealed record CreateReservationCommand(ReservationWriteDto Reservation) : ICommand; diff --git a/StudioManager.Application/Reservations/Create/CreateReservationCommandHandler.cs b/StudioManager.Application/Reservations/Create/CreateReservationCommandHandler.cs index 394cc16..8930b52 100644 --- a/StudioManager.Application/Reservations/Create/CreateReservationCommandHandler.cs +++ b/StudioManager.Application/Reservations/Create/CreateReservationCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.Reservations.Common; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Entities; @@ -10,7 +9,7 @@ namespace StudioManager.Application.Reservations.Create; public sealed class CreateReservationCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(CreateReservationCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/Reservations/Delete/DeleteReservationCommand.cs b/StudioManager.Application/Reservations/Delete/DeleteReservationCommand.cs index 6929833..3dc0efd 100644 --- a/StudioManager.Application/Reservations/Delete/DeleteReservationCommand.cs +++ b/StudioManager.Application/Reservations/Delete/DeleteReservationCommand.cs @@ -1,6 +1,5 @@ -using MediatR; -using StudioManager.Domain.Common.Results; +using StudioManager.Domain.Common.Results; namespace StudioManager.Application.Reservations.Delete; -public sealed record DeleteReservationCommand(Guid Id) : IRequest; +public sealed record DeleteReservationCommand(Guid Id) : ICommand; diff --git a/StudioManager.Application/Reservations/Delete/DeleteReservationCommandHandler.cs b/StudioManager.Application/Reservations/Delete/DeleteReservationCommandHandler.cs index 7104322..86e0b63 100644 --- a/StudioManager.Application/Reservations/Delete/DeleteReservationCommandHandler.cs +++ b/StudioManager.Application/Reservations/Delete/DeleteReservationCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.DbContextExtensions; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Entities; @@ -10,7 +9,7 @@ namespace StudioManager.Application.Reservations.Delete; public sealed class DeleteReservationCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(DeleteReservationCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/Reservations/GetAll/GetAllReservationsQuery.cs b/StudioManager.Application/Reservations/GetAll/GetAllReservationsQuery.cs index 432d437..dd4532f 100644 --- a/StudioManager.Application/Reservations/GetAll/GetAllReservationsQuery.cs +++ b/StudioManager.Application/Reservations/GetAll/GetAllReservationsQuery.cs @@ -1,5 +1,4 @@ -using MediatR; -using StudioManager.API.Contracts.Pagination; +using StudioManager.API.Contracts.Pagination; using StudioManager.API.Contracts.Reservations; using StudioManager.Domain.Common.Results; using StudioManager.Domain.Filters; @@ -9,7 +8,7 @@ namespace StudioManager.Application.Reservations.GetAll; public sealed class GetAllReservationsQuery( ReservationFilter filter, PaginationDto pagination) - : IRequest>> + : IQuery> { public ReservationFilter Filter { get; } = filter; public PaginationDto Pagination { get; } = pagination; diff --git a/StudioManager.Application/Reservations/GetAll/GetAllReservationsQueryHandler.cs b/StudioManager.Application/Reservations/GetAll/GetAllReservationsQueryHandler.cs index f29ad9d..105d8d3 100644 --- a/StudioManager.Application/Reservations/GetAll/GetAllReservationsQueryHandler.cs +++ b/StudioManager.Application/Reservations/GetAll/GetAllReservationsQueryHandler.cs @@ -1,6 +1,5 @@ using AutoMapper; using AutoMapper.QueryableExtensions; -using MediatR; using Microsoft.EntityFrameworkCore; using StudioManager.API.Contracts.Pagination; using StudioManager.API.Contracts.Reservations; @@ -13,7 +12,7 @@ namespace StudioManager.Application.Reservations.GetAll; public sealed class GetAllReservationsQueryHandler( IDbContextFactory dbContextFactory, IMapper mapper) - : IRequestHandler>> + : IQueryHandler> { public async Task>> Handle(GetAllReservationsQuery request, CancellationToken cancellationToken) diff --git a/StudioManager.Application/Reservations/GetById/GetReservationByIdQuery.cs b/StudioManager.Application/Reservations/GetById/GetReservationByIdQuery.cs new file mode 100644 index 0000000..6303e1f --- /dev/null +++ b/StudioManager.Application/Reservations/GetById/GetReservationByIdQuery.cs @@ -0,0 +1,9 @@ +using StudioManager.API.Contracts.Reservations; +using StudioManager.Domain.Common.Results; + +namespace StudioManager.Application.Reservations.GetById; + +public sealed record GetReservationByIdQuery(Guid Id) : IQuery +{ + public Guid Id { get; } = Id; +} diff --git a/StudioManager.Application/Reservations/BetById/GetReservationByIdQueryHandler.cs b/StudioManager.Application/Reservations/GetById/GetReservationByIdQueryHandler.cs similarity index 81% rename from StudioManager.Application/Reservations/BetById/GetReservationByIdQueryHandler.cs rename to StudioManager.Application/Reservations/GetById/GetReservationByIdQueryHandler.cs index 97b2a59..4e7dd02 100644 --- a/StudioManager.Application/Reservations/BetById/GetReservationByIdQueryHandler.cs +++ b/StudioManager.Application/Reservations/GetById/GetReservationByIdQueryHandler.cs @@ -1,20 +1,20 @@ using AutoMapper; using AutoMapper.QueryableExtensions; -using MediatR; using Microsoft.EntityFrameworkCore; using StudioManager.API.Contracts.Reservations; using StudioManager.Domain.Common.Results; using StudioManager.Domain.ErrorMessages; using StudioManager.Infrastructure; -namespace StudioManager.Application.Reservations.BetById; +namespace StudioManager.Application.Reservations.GetById; public sealed class GetReservationByIdQueryHandler( IDbContextFactory dbContextFactory, IMapper mapper) - : IRequestHandler> + : IQueryHandler { - public async Task> Handle(GetReservationByIdQuery request, CancellationToken cancellationToken) + public async Task> Handle(GetReservationByIdQuery request, + CancellationToken cancellationToken) { await using var dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); @@ -23,7 +23,7 @@ public async Task> Handle(GetReservationByIdQuer .Where(x => x.Id == request.Id) .ProjectTo(mapper.ConfigurationProvider) .FirstOrDefaultAsync(cancellationToken); - + return reservation is null ? QueryResult.NotFound(string.Format(DB_FORMAT.RESERVATION_NOT_FOUND, request.Id)) : QueryResult.Success(reservation); diff --git a/StudioManager.Application/Reservations/BetById/GetReservationByIdQueryValidator.cs b/StudioManager.Application/Reservations/GetById/GetReservationByIdQueryValidator.cs similarity index 79% rename from StudioManager.Application/Reservations/BetById/GetReservationByIdQueryValidator.cs rename to StudioManager.Application/Reservations/GetById/GetReservationByIdQueryValidator.cs index 158a6d4..3877168 100644 --- a/StudioManager.Application/Reservations/BetById/GetReservationByIdQueryValidator.cs +++ b/StudioManager.Application/Reservations/GetById/GetReservationByIdQueryValidator.cs @@ -1,6 +1,6 @@ using FluentValidation; -namespace StudioManager.Application.Reservations.BetById; +namespace StudioManager.Application.Reservations.GetById; public sealed class GetReservationByIdQueryValidator : AbstractValidator { diff --git a/StudioManager.Application/Reservations/Update/UpdateReservationCommand.cs b/StudioManager.Application/Reservations/Update/UpdateReservationCommand.cs index e39e102..25ae5cd 100644 --- a/StudioManager.Application/Reservations/Update/UpdateReservationCommand.cs +++ b/StudioManager.Application/Reservations/Update/UpdateReservationCommand.cs @@ -1,7 +1,6 @@ -using MediatR; -using StudioManager.API.Contracts.Reservations; +using StudioManager.API.Contracts.Reservations; using StudioManager.Domain.Common.Results; namespace StudioManager.Application.Reservations.Update; -public sealed record UpdateReservationCommand(Guid Id, ReservationWriteDto Reservation) : IRequest; +public sealed record UpdateReservationCommand(Guid Id, ReservationWriteDto Reservation) : ICommand; diff --git a/StudioManager.Application/Reservations/Update/UpdateReservationCommandHandler.cs b/StudioManager.Application/Reservations/Update/UpdateReservationCommandHandler.cs index a745f13..b9fbeed 100644 --- a/StudioManager.Application/Reservations/Update/UpdateReservationCommandHandler.cs +++ b/StudioManager.Application/Reservations/Update/UpdateReservationCommandHandler.cs @@ -1,5 +1,4 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using StudioManager.Application.DbContextExtensions; using StudioManager.Application.Reservations.Common; using StudioManager.Domain.Common.Results; @@ -10,7 +9,7 @@ namespace StudioManager.Application.Reservations.Update; public sealed class UpdateReservationCommandHandler( IDbContextFactory dbContextFactory) - : IRequestHandler + : ICommandHandler { public async Task Handle(UpdateReservationCommand request, CancellationToken cancellationToken) { diff --git a/StudioManager.Application/StudioManager.Application.csproj b/StudioManager.Application/StudioManager.Application.csproj index 8519368..ee534df 100644 --- a/StudioManager.Application/StudioManager.Application.csproj +++ b/StudioManager.Application/StudioManager.Application.csproj @@ -16,7 +16,6 @@ - diff --git a/StudioManager.Domain/Common/Results/ICommand.cs b/StudioManager.Domain/Common/Results/ICommand.cs new file mode 100644 index 0000000..216639f --- /dev/null +++ b/StudioManager.Domain/Common/Results/ICommand.cs @@ -0,0 +1,5 @@ +using MediatR; + +namespace StudioManager.Domain.Common.Results; + +public interface ICommand : IRequest; diff --git a/StudioManager.Domain/Common/Results/ICommandHandler.cs b/StudioManager.Domain/Common/Results/ICommandHandler.cs new file mode 100644 index 0000000..52a758f --- /dev/null +++ b/StudioManager.Domain/Common/Results/ICommandHandler.cs @@ -0,0 +1,6 @@ +using MediatR; + +namespace StudioManager.Domain.Common.Results; + +public interface ICommandHandler : IRequestHandler + where TCommand : IRequest; diff --git a/StudioManager.Domain/Common/Results/IQuery.cs b/StudioManager.Domain/Common/Results/IQuery.cs new file mode 100644 index 0000000..b63da06 --- /dev/null +++ b/StudioManager.Domain/Common/Results/IQuery.cs @@ -0,0 +1,5 @@ +using MediatR; + +namespace StudioManager.Domain.Common.Results; + +public interface IQuery : IRequest>; diff --git a/StudioManager.Domain/Common/Results/IQueryHandler.cs b/StudioManager.Domain/Common/Results/IQueryHandler.cs new file mode 100644 index 0000000..cd6632a --- /dev/null +++ b/StudioManager.Domain/Common/Results/IQueryHandler.cs @@ -0,0 +1,6 @@ +using MediatR; + +namespace StudioManager.Domain.Common.Results; + +public interface IQueryHandler : IRequestHandler> + where TQuery : IRequest>;