Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place the command files in the corresponding folder #550

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Ordering.API/Apis/OrdersApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Microsoft.AspNetCore.Http.HttpResults;
using eShop.Ordering.API.Application.Commands.CancelOrder;
using eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.Commands.CreateOrderDraft;
using eShop.Ordering.API.Application.Commands.Identified;
using eShop.Ordering.API.Application.Commands.ShipOrder;
using Microsoft.AspNetCore.Http.HttpResults;
using CardType = eShop.Ordering.API.Application.Queries.CardType;
using Order = eShop.Ordering.API.Application.Queries.Order;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.CancelOrder;

public record CancelOrderCommand(int OrderNumber) : IRequest<bool>;

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Commands;
using eShop.Ordering.API.Application.Commands.Identified;

namespace eShop.Ordering.API.Application.Commands.CancelOrder;

// Regular CommandHandler
public class CancelOrderCommandHandler : IRequestHandler<CancelOrderCommand, bool>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.CreateOrder;

using eShop.Ordering.API.Application.Commands.CreateOrderDraft;

// DDD and CQRS patterns comment: Note that it is recommended to implement immutable Commands
// In this case, its immutability is achieved by having all the setters as private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace eShop.Ordering.API.Application.Commands;

namespace eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.Commands.Identified;
using eShop.Ordering.Domain.AggregatesModel.OrderAggregate;

// Regular CommandHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.CreateOrderDraft;

using eShop.Ordering.API.Application.Models;

public record CreateOrderDraftCommand(string BuyerId, IEnumerable<BasketItem> Items) : IRequest<OrderDraftDTO>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.CreateOrderDraft;

using eShop.Ordering.API.Extensions;
using eShop.Ordering.Domain.AggregatesModel.OrderAggregate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.Identified;

public class IdentifiedCommand<T, R> : IRequest<R>
where T : IRequest<R>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace eShop.Ordering.API.Application.Commands;
using eShop.Ordering.API.Application.Commands.CancelOrder;
using eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.Commands.ShipOrder;

namespace eShop.Ordering.API.Application.Commands.Identified;

/// <summary>
/// Provides a base implementation for handling duplicate request and ensuring idempotent updates, in the cases where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.SetAwaitingValidationOrderStatus;

public record SetAwaitingValidationOrderStatusCommand(int OrderNumber) : IRequest<bool>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Commands;
using eShop.Ordering.API.Application.Commands.Identified;

namespace eShop.Ordering.API.Application.Commands.SetAwaitingValidationOrderStatus;

// Regular CommandHandler
public class SetAwaitingValidationOrderStatusCommandHandler : IRequestHandler<SetAwaitingValidationOrderStatusCommand, bool>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.SetPaidOrderStatus;

public record SetPaidOrderStatusCommand(int OrderNumber) : IRequest<bool>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Commands;
using eShop.Ordering.API.Application.Commands.Identified;

namespace eShop.Ordering.API.Application.Commands.SetPaidOrderStatus;

// Regular CommandHandler
public class SetPaidOrderStatusCommandHandler : IRequestHandler<SetPaidOrderStatusCommand, bool>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.SetStockConfirmedOrderStatus;

public record SetStockConfirmedOrderStatusCommand(int OrderNumber) : IRequest<bool>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Commands;
using eShop.Ordering.API.Application.Commands.Identified;

namespace eShop.Ordering.API.Application.Commands.SetStockConfirmedOrderStatus;

// Regular CommandHandler
public class SetStockConfirmedOrderStatusCommandHandler : IRequestHandler<SetStockConfirmedOrderStatusCommand, bool>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.SetStockRejectedOrderStatus;

public record SetStockRejectedOrderStatusCommand(int OrderNumber, List<int> OrderStockItems) : IRequest<bool>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Commands;
using eShop.Ordering.API.Application.Commands.Identified;

namespace eShop.Ordering.API.Application.Commands.SetStockRejectedOrderStatus;

// Regular CommandHandler
public class SetStockRejectedOrderStatusCommandHandler : IRequestHandler<SetStockRejectedOrderStatusCommand, bool>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace eShop.Ordering.API.Application.Commands;
namespace eShop.Ordering.API.Application.Commands.ShipOrder;

public record ShipOrderCommand(int OrderNumber) : IRequest<bool>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Commands;
using eShop.Ordering.API.Application.Commands.Identified;

namespace eShop.Ordering.API.Application.Commands.ShipOrder;

// Regular CommandHandler
public class ShipOrderCommandHandler : IRequestHandler<ShipOrderCommand, bool>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;
using eShop.Ordering.API.Application.Commands.SetAwaitingValidationOrderStatus;

namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;

public class GracePeriodConfirmedIntegrationEventHandler(
IMediator mediator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;
using eShop.Ordering.API.Application.Commands.CancelOrder;

namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;

public class OrderPaymentFailedIntegrationEventHandler(
IMediator mediator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;
using eShop.Ordering.API.Application.Commands.SetPaidOrderStatus;

namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;

public class OrderPaymentSucceededIntegrationEventHandler(
IMediator mediator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;
using eShop.Ordering.API.Application.Commands.SetStockConfirmedOrderStatus;

namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;

public class OrderStockConfirmedIntegrationEventHandler(
IMediator mediator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;
using eShop.Ordering.API.Application.Commands.SetStockRejectedOrderStatus;

namespace eShop.Ordering.API.Application.IntegrationEvents.EventHandling;
public class OrderStockRejectedIntegrationEventHandler(
IMediator mediator,
ILogger<OrderStockRejectedIntegrationEventHandler> logger) : IIntegrationEventHandler<OrderStockRejectedIntegrationEvent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Validations;
using eShop.Ordering.API.Application.Commands.CancelOrder;

namespace eShop.Ordering.API.Application.Validations;

public class CancelOrderCommandValidator : AbstractValidator<CancelOrderCommand>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace eShop.Ordering.API.Application.Validations;
using eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.Commands.CreateOrderDraft;

namespace eShop.Ordering.API.Application.Validations;
public class CreateOrderCommandValidator : AbstractValidator<CreateOrderCommand>
{
public CreateOrderCommandValidator(ILogger<CreateOrderCommandValidator> logger)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace eShop.Ordering.API.Application.Validations;
using eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.Commands.Identified;

namespace eShop.Ordering.API.Application.Validations;

public class IdentifiedCommandValidator : AbstractValidator<IdentifiedCommand<CreateOrderCommand, bool>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Application.Validations;
using eShop.Ordering.API.Application.Commands.ShipOrder;

namespace eShop.Ordering.API.Application.Validations;

public class ShipOrderCommandValidator : AbstractValidator<ShipOrderCommand>
{
Expand Down
4 changes: 3 additions & 1 deletion src/Ordering.API/Extensions/BasketItemExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace eShop.Ordering.API.Extensions;
using eShop.Ordering.API.Application.Commands.CreateOrderDraft;

namespace eShop.Ordering.API.Extensions;

public static class BasketItemExtensions
{
Expand Down
7 changes: 6 additions & 1 deletion src/Ordering.API/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
internal static class Extensions
using eShop.Ordering.API.Application.Commands.CancelOrder;
using eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.Commands.Identified;
using eShop.Ordering.API.Application.Commands.ShipOrder;

internal static class Extensions
{
public static void AddApplicationServices(this IHostApplicationBuilder builder)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Ordering.FunctionalTests/OrderingApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Text.Json;
using Asp.Versioning;
using Asp.Versioning.Http;
using eShop.Ordering.API.Application.Commands;
using eShop.Ordering.API.Application.Commands.CreateOrderDraft;
using eShop.Ordering.API.Application.Models;
using eShop.Ordering.API.Application.Queries;
using Microsoft.AspNetCore.Mvc.Testing;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace eShop.Ordering.UnitTests.Application;
using eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.Commands.Identified;

namespace eShop.Ordering.UnitTests.Application;

[TestClass]
public class IdentifiedCommandHandlerTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using eShop.Ordering.API.Application.IntegrationEvents;
using eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.IntegrationEvents;
using eShop.Ordering.Domain.AggregatesModel.OrderAggregate;

namespace eShop.Ordering.UnitTests.Application;
Expand Down
4 changes: 4 additions & 0 deletions tests/Ordering.UnitTests/Application/OrdersWebApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
using eShop.Ordering.API.Application.Queries;
using Order = eShop.Ordering.API.Application.Queries.Order;
using NSubstitute.ExceptionExtensions;
using eShop.Ordering.API.Application.Commands.CancelOrder;
using eShop.Ordering.API.Application.Commands.CreateOrder;
using eShop.Ordering.API.Application.Commands.Identified;
using eShop.Ordering.API.Application.Commands.ShipOrder;

[TestClass]
public class OrdersWebApiTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json;
using eShop.Ordering.API.Application.Commands.SetStockRejectedOrderStatus;

namespace eShop.Ordering.UnitTests.Application;

Expand Down