Domain модели
This commit is contained in:
25
.vscode/launch.json
vendored
25
.vscode/launch.json
vendored
@@ -21,6 +21,31 @@
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
},
|
||||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/src/ApiServer/bin/Debug/net10.0/ApiServer.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/src/ApiServer",
|
||||
"stopAtEntry": false,
|
||||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
6
.vscode/tasks.json
vendored
6
.vscode/tasks.json
vendored
@@ -7,7 +7,7 @@
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/src/Console/Console.csproj",
|
||||
"${workspaceFolder}/src/ApiServer/ApiServer.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||
],
|
||||
@@ -19,7 +19,7 @@
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/src/Console/Console.csproj",
|
||||
"${workspaceFolder}/src/ApiServer/ApiServer.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||
],
|
||||
@@ -33,7 +33,7 @@
|
||||
"watch",
|
||||
"run",
|
||||
"--project",
|
||||
"${workspaceFolder}/src/Console/Console.csproj"
|
||||
"${workspaceFolder}/src/ApiServer/ApiServer.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Domain;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
24
src/Domain/Entities/Dish.cs
Normal file
24
src/Domain/Entities/Dish.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Блюдо из меню (GetMenu / MenuItem).
|
||||
/// </summary>
|
||||
public sealed class Dish
|
||||
{
|
||||
public required string Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Артикул блюда. Используется при вводе заказа с клавиатуры.
|
||||
/// </summary>
|
||||
public required string Article { get; init; }
|
||||
|
||||
public required string Name { get; init; }
|
||||
|
||||
public decimal Price { get; init; }
|
||||
|
||||
public bool IsWeighted { get; init; }
|
||||
|
||||
public required string FullPath { get; init; }
|
||||
|
||||
public IReadOnlyList<string> Barcodes { get; init; } = [];
|
||||
}
|
||||
37
src/Domain/Entities/Order.cs
Normal file
37
src/Domain/Entities/Order.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Заказ (SendOrder).
|
||||
/// </summary>
|
||||
public sealed class Order
|
||||
{
|
||||
private readonly List<OrderItem> _items = [];
|
||||
|
||||
public Guid Id { get; }
|
||||
|
||||
public IReadOnlyCollection<OrderItem> Items => _items;
|
||||
|
||||
public Order(Guid? id = null)
|
||||
{
|
||||
Id = id ?? Guid.NewGuid();
|
||||
}
|
||||
|
||||
public void AddItem(string menuItemId, decimal quantity)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(menuItemId);
|
||||
|
||||
if (quantity <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(quantity),
|
||||
quantity,
|
||||
"Количество должно быть больше нуля.");
|
||||
}
|
||||
|
||||
_items.Add(new OrderItem
|
||||
{
|
||||
MenuItemId = menuItemId,
|
||||
Quantity = quantity,
|
||||
});
|
||||
}
|
||||
}
|
||||
17
src/Domain/Entities/OrderItem.cs
Normal file
17
src/Domain/Entities/OrderItem.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Позиция заказа (SendOrder / MenuItems).
|
||||
/// </summary>
|
||||
public sealed class OrderItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор блюда на сервере (<see cref="Dish.Id"/>).
|
||||
/// </summary>
|
||||
public required string MenuItemId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Количество. Для весовых блюд допускаются дробные значения.
|
||||
/// </summary>
|
||||
public decimal Quantity { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user