Skip to content

Commit a102824

Browse files
feature: this commit introduces a new boundary responsible for order management, migrating the organization and repository to a monorepo structure
1 parent ba3a69d commit a102824

77 files changed

Lines changed: 2205 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
MONGO_INITDB_ROOT_USERNAME=admin
2+
MONGO_INITDB_ROOT_PASSWORD=admin
3+
4+
SEQ_FIRSTRUN_ADMINPASSWORD=admin
5+
6+
MONGO_CONNECTIONSTRING=mongodb://admin:admin@comanda.orders.infrastructure.mongo.database:27017/comanda-orders?authSource=admin
7+
MONGO_DATABASENAME=comanda-orders
8+
9+
ADMIN_USERNAME=admin
10+
ADMIN_PASSWORD=admin
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{B8EFCA5F-814F-285C-A8CB-F00F14650265}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Comanda.Orders.Domain", "Source\Comanda.Orders.Domain\Comanda.Orders.Domain.csproj", "{C7293B3C-E854-443D-8BB8-D79A81380162}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Comanda.Orders.Application", "Source\Comanda.Orders.Application\Comanda.Orders.Application.csproj", "{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Comanda.Orders.Infrastructure", "Source\Comanda.Orders.Infrastructure\Comanda.Orders.Infrastructure.csproj", "{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Comanda.Orders.Infrastructure.IoC", "Source\Comanda.Orders.Infrastructure.IoC\Comanda.Orders.Infrastructure.IoC.csproj", "{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Comanda.Orders.WebApi", "Source\Comanda.Orders.WebApi\Comanda.Orders.WebApi.csproj", "{37A746D8-CD9D-449A-AB1B-2C02F5366694}"
17+
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Comanda.Orders.CrossCutting", "Source\Comanda.Orders.CrossCutting\Comanda.Orders.CrossCutting.csproj", "{F218FF09-497E-4E48-A960-2BE2A0FD38F1}"
19+
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}"
21+
EndProject
22+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Comanda.Orders.TestSuite", "Tests\Comanda.Orders.TestSuite.csproj", "{8434AF6E-FEDA-4692-A448-720429C00800}"
23+
EndProject
24+
Global
25+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
26+
Debug|Any CPU = Debug|Any CPU
27+
Debug|x64 = Debug|x64
28+
Debug|x86 = Debug|x86
29+
Release|Any CPU = Release|Any CPU
30+
Release|x64 = Release|x64
31+
Release|x86 = Release|x86
32+
EndGlobalSection
33+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
34+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Debug|x64.ActiveCfg = Debug|Any CPU
37+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Debug|x64.Build.0 = Debug|Any CPU
38+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Debug|x86.ActiveCfg = Debug|Any CPU
39+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Debug|x86.Build.0 = Debug|Any CPU
40+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Release|Any CPU.Build.0 = Release|Any CPU
42+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Release|x64.ActiveCfg = Release|Any CPU
43+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Release|x64.Build.0 = Release|Any CPU
44+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Release|x86.ActiveCfg = Release|Any CPU
45+
{C7293B3C-E854-443D-8BB8-D79A81380162}.Release|x86.Build.0 = Release|Any CPU
46+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Debug|x64.ActiveCfg = Debug|Any CPU
49+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Debug|x64.Build.0 = Debug|Any CPU
50+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Debug|x86.ActiveCfg = Debug|Any CPU
51+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Debug|x86.Build.0 = Debug|Any CPU
52+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Release|x64.ActiveCfg = Release|Any CPU
55+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Release|x64.Build.0 = Release|Any CPU
56+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Release|x86.ActiveCfg = Release|Any CPU
57+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF}.Release|x86.Build.0 = Release|Any CPU
58+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
60+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Debug|x64.ActiveCfg = Debug|Any CPU
61+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Debug|x64.Build.0 = Debug|Any CPU
62+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Debug|x86.ActiveCfg = Debug|Any CPU
63+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Debug|x86.Build.0 = Debug|Any CPU
64+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Release|Any CPU.Build.0 = Release|Any CPU
66+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Release|x64.ActiveCfg = Release|Any CPU
67+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Release|x64.Build.0 = Release|Any CPU
68+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Release|x86.ActiveCfg = Release|Any CPU
69+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3}.Release|x86.Build.0 = Release|Any CPU
70+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Debug|Any CPU.Build.0 = Debug|Any CPU
72+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Debug|x64.ActiveCfg = Debug|Any CPU
73+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Debug|x64.Build.0 = Debug|Any CPU
74+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Debug|x86.ActiveCfg = Debug|Any CPU
75+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Debug|x86.Build.0 = Debug|Any CPU
76+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Release|Any CPU.ActiveCfg = Release|Any CPU
77+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Release|Any CPU.Build.0 = Release|Any CPU
78+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Release|x64.ActiveCfg = Release|Any CPU
79+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Release|x64.Build.0 = Release|Any CPU
80+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Release|x86.ActiveCfg = Release|Any CPU
81+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14}.Release|x86.Build.0 = Release|Any CPU
82+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Debug|Any CPU.Build.0 = Debug|Any CPU
84+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Debug|x64.ActiveCfg = Debug|Any CPU
85+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Debug|x64.Build.0 = Debug|Any CPU
86+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Debug|x86.ActiveCfg = Debug|Any CPU
87+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Debug|x86.Build.0 = Debug|Any CPU
88+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Release|Any CPU.ActiveCfg = Release|Any CPU
89+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Release|Any CPU.Build.0 = Release|Any CPU
90+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Release|x64.ActiveCfg = Release|Any CPU
91+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Release|x64.Build.0 = Release|Any CPU
92+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Release|x86.ActiveCfg = Release|Any CPU
93+
{37A746D8-CD9D-449A-AB1B-2C02F5366694}.Release|x86.Build.0 = Release|Any CPU
94+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
96+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Debug|x64.ActiveCfg = Debug|Any CPU
97+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Debug|x64.Build.0 = Debug|Any CPU
98+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Debug|x86.ActiveCfg = Debug|Any CPU
99+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Debug|x86.Build.0 = Debug|Any CPU
100+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
101+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Release|Any CPU.Build.0 = Release|Any CPU
102+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Release|x64.ActiveCfg = Release|Any CPU
103+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Release|x64.Build.0 = Release|Any CPU
104+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Release|x86.ActiveCfg = Release|Any CPU
105+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1}.Release|x86.Build.0 = Release|Any CPU
106+
{8434AF6E-FEDA-4692-A448-720429C00800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
107+
{8434AF6E-FEDA-4692-A448-720429C00800}.Debug|Any CPU.Build.0 = Debug|Any CPU
108+
{8434AF6E-FEDA-4692-A448-720429C00800}.Debug|x64.ActiveCfg = Debug|Any CPU
109+
{8434AF6E-FEDA-4692-A448-720429C00800}.Debug|x64.Build.0 = Debug|Any CPU
110+
{8434AF6E-FEDA-4692-A448-720429C00800}.Debug|x86.ActiveCfg = Debug|Any CPU
111+
{8434AF6E-FEDA-4692-A448-720429C00800}.Debug|x86.Build.0 = Debug|Any CPU
112+
{8434AF6E-FEDA-4692-A448-720429C00800}.Release|Any CPU.ActiveCfg = Release|Any CPU
113+
{8434AF6E-FEDA-4692-A448-720429C00800}.Release|Any CPU.Build.0 = Release|Any CPU
114+
{8434AF6E-FEDA-4692-A448-720429C00800}.Release|x64.ActiveCfg = Release|Any CPU
115+
{8434AF6E-FEDA-4692-A448-720429C00800}.Release|x64.Build.0 = Release|Any CPU
116+
{8434AF6E-FEDA-4692-A448-720429C00800}.Release|x86.ActiveCfg = Release|Any CPU
117+
{8434AF6E-FEDA-4692-A448-720429C00800}.Release|x86.Build.0 = Release|Any CPU
118+
EndGlobalSection
119+
GlobalSection(SolutionProperties) = preSolution
120+
HideSolutionNode = FALSE
121+
EndGlobalSection
122+
GlobalSection(NestedProjects) = preSolution
123+
{C7293B3C-E854-443D-8BB8-D79A81380162} = {B8EFCA5F-814F-285C-A8CB-F00F14650265}
124+
{5B4760C0-F3BD-4837-8D1B-19E59A13BDDF} = {B8EFCA5F-814F-285C-A8CB-F00F14650265}
125+
{31C332BD-1EA3-4A7B-B737-BCB46C78AFF3} = {B8EFCA5F-814F-285C-A8CB-F00F14650265}
126+
{329A734D-2607-40FD-9ED2-3BF7ABEC2A14} = {B8EFCA5F-814F-285C-A8CB-F00F14650265}
127+
{37A746D8-CD9D-449A-AB1B-2C02F5366694} = {B8EFCA5F-814F-285C-A8CB-F00F14650265}
128+
{F218FF09-497E-4E48-A960-2BE2A0FD38F1} = {B8EFCA5F-814F-285C-A8CB-F00F14650265}
129+
{8434AF6E-FEDA-4692-A448-720429C00800} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
130+
EndGlobalSection
131+
EndGlobal
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# use ASP.NET Core 9.0 runtime image as base
2+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
3+
WORKDIR /app
4+
EXPOSE 8085
5+
6+
# use SDK image for build
7+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
8+
WORKDIR /src
9+
10+
# copy project files to restore dependencies
11+
COPY ["Source/Comanda.Orders.WebApi/Comanda.Orders.WebApi.csproj", "Comanda.Orders.WebApi/"]
12+
13+
# copy the entire solution 'n related projects
14+
COPY ["Comanda.Orders.sln", "./"]
15+
16+
# restore dependencies for the project
17+
RUN dotnet restore "Comanda.Orders.WebApi/Comanda.Orders.WebApi.csproj"
18+
19+
# copy all source code into the container
20+
COPY Source/ ./Source/
21+
22+
# set working directory to the web project
23+
WORKDIR "/src/Source/Comanda.Orders.WebApi"
24+
25+
# build in Release mode
26+
RUN dotnet build "Comanda.Orders.WebApi.csproj" -c Release -o /app/build
27+
28+
# publish the project for production
29+
FROM build AS publish
30+
RUN dotnet publish "Comanda.Orders.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
31+
32+
# final image to run the app
33+
FROM base AS final
34+
WORKDIR /app
35+
36+
# copy published files from the publish stage
37+
COPY --from=publish /app/publish .
38+
39+
# set the command to start the application
40+
ENTRYPOINT ["dotnet", "Comanda.Orders.WebApi.dll"]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="FluentValidation" Version="12.0.0" />
11+
<PackageReference Include="Comanda.Internal.Contracts" Version="1.0.1" />
12+
<PackageReference Include="HttpsRichardy.Dispatcher" Version="1.0.2" />
13+
<PackageReference Include="HttpsRichardy.Federation.Sdk.Contracts" Version="1.0.2" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="../Comanda.Orders.Domain/Comanda.Orders.Domain.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Comanda.Orders.Application.Handlers.Order;
2+
3+
public sealed class OrderCreationHandler(IOrderCollection repository, IOrderService service) :
4+
IDispatchHandler<OrderCreationScheme, Result<OrderScheme>>
5+
{
6+
public async Task<Result<OrderScheme>> HandleAsync(
7+
OrderCreationScheme parameters, CancellationToken cancellation = default)
8+
{
9+
var code = await service.GenerateCodeAsync(cancellation);
10+
var order = await repository.InsertAsync(parameters.AsOrder(code), cancellation: cancellation);
11+
12+
return Result<OrderScheme>.Success(order.AsResponse());
13+
}
14+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace Comanda.Orders.Application.Handlers.Order;
2+
3+
public sealed class OrderModificationHandler(IOrderCollection repository) :
4+
IDispatchHandler<OrderModificationScheme, Result<OrderScheme>>
5+
{
6+
public async Task<Result<OrderScheme>> HandleAsync(
7+
OrderModificationScheme parameters, CancellationToken cancellation = default)
8+
{
9+
var filters = OrderFilters.WithSpecifications()
10+
.WithIdentifier(parameters.Id)
11+
.Build();
12+
13+
var orders = await repository.GetOrdersAsync(filters, cancellation);
14+
var existingOrder = orders.FirstOrDefault();
15+
16+
if (existingOrder is null)
17+
{
18+
return Result<OrderScheme>.Failure(OrderErrors.OrderDoesNotExist);
19+
}
20+
21+
existingOrder.WithChanges(builder =>
22+
{
23+
builder.SetStatus(parameters.Status);
24+
builder.SetPriority(parameters.Priority);
25+
});
26+
27+
var order = await repository.UpdateAsync(existingOrder, cancellation);
28+
29+
return Result<OrderScheme>.Success(order.AsResponse());
30+
}
31+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Comanda.Orders.Application.Handlers.Order;
2+
3+
public sealed class OrdersFetchHandler(IOrderCollection repository) :
4+
IDispatchHandler<OrdersFetchParameters, Result<PaginationScheme<OrderScheme>>>
5+
{
6+
public async Task<Result<PaginationScheme<OrderScheme>>> HandleAsync(
7+
OrdersFetchParameters parameters, CancellationToken cancellation = default)
8+
{
9+
var filters = parameters.AsFilters();
10+
11+
var orders = await repository.GetOrdersAsync(filters, cancellation);
12+
var total = await repository.CountOrdersAsync(filters, cancellation);
13+
14+
var pagination = new PaginationScheme<OrderScheme>
15+
{
16+
Items = [.. orders.Select(order => order.AsResponse())],
17+
Total = (int)total,
18+
19+
PageSize = parameters.Pagination?.PageSize ?? 1,
20+
PageNumber = parameters.Pagination?.PageNumber ?? 20
21+
};
22+
23+
return Result<PaginationScheme<OrderScheme>>.Success(pagination);
24+
}
25+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
namespace Comanda.Orders.Application.Mappers;
2+
3+
public static class OrderMapper
4+
{
5+
public static Order AsOrder(this OrderCreationScheme scheme, Code code)
6+
{
7+
var order = new Order
8+
{
9+
Code = code,
10+
Fulfillment = scheme.Fulfillment,
11+
Priority = scheme.Priority,
12+
Metadata = scheme.Metadata,
13+
Items = [.. scheme.Items],
14+
};
15+
16+
return order;
17+
}
18+
19+
public static OrderFilters AsFilters(this OrdersFetchParameters parameters) => new()
20+
{
21+
Id = parameters.Id,
22+
Code = parameters.Code,
23+
24+
MerchantId = parameters.MerchantId,
25+
ConsumerId = parameters.ConsumerId,
26+
27+
Pagination = parameters.Pagination,
28+
Sort = parameters.Sort,
29+
30+
CreatedAfter = parameters.CreatedAfter,
31+
CreatedBefore = parameters.CreatedBefore,
32+
33+
Status = string.IsNullOrWhiteSpace(parameters.Status)
34+
? null
35+
: Enum.Parse<Status>(parameters.Status, ignoreCase: true),
36+
37+
Priority = string.IsNullOrWhiteSpace(parameters.Priority)
38+
? null
39+
: Enum.Parse<Priority>(parameters.Priority, ignoreCase: true),
40+
41+
Fulfillment = string.IsNullOrWhiteSpace(parameters.Fulfillment)
42+
? null
43+
: Enum.Parse<Fulfillment>(parameters.Fulfillment, ignoreCase: true)
44+
};
45+
46+
public static OrderScheme AsResponse(this Order order) => new()
47+
{
48+
Identifier = order.Id,
49+
Code = order.Code.Identifier,
50+
Priority = order.Priority,
51+
Status = order.Status,
52+
Fulfillment = order.Fulfillment,
53+
Items = [.. order.Items],
54+
Metadata = order.Metadata,
55+
};
56+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Comanda.Orders.Application.Payloads.Order;
2+
3+
public sealed record OrderCreationScheme : IDispatchable<Result<OrderScheme>>
4+
{
5+
public Fulfillment Fulfillment { get; init; }
6+
public Priority Priority { get; init; }
7+
public Metadata Metadata { get; init; } = default!;
8+
public IEnumerable<Item> Items { get; init; } = [];
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Comanda.Orders.Application.Payloads.Order;
2+
3+
public sealed record OrderModificationScheme : IDispatchable<Result<OrderScheme>>
4+
{
5+
[property: JsonIgnore]
6+
public string Id { get; init; } = default!;
7+
8+
public Status Status { get; init; }
9+
public Priority Priority { get; init; }
10+
}

0 commit comments

Comments
 (0)