diff --git a/.vscode/launch.json b/.vscode/launch.json index 565793d..e26b9f5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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" + } } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6661519..169c575 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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" } diff --git a/src/Domain/Class1.cs b/src/Domain/Class1.cs deleted file mode 100644 index 610aa88..0000000 --- a/src/Domain/Class1.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Domain; - -public class Class1 -{ - -} diff --git a/src/Domain/Entities/Dish.cs b/src/Domain/Entities/Dish.cs new file mode 100644 index 0000000..5521f5a --- /dev/null +++ b/src/Domain/Entities/Dish.cs @@ -0,0 +1,24 @@ +namespace Domain.Entities; + +/// +/// Блюдо из меню (GetMenu / MenuItem). +/// +public sealed class Dish +{ + public required string Id { get; init; } + + /// + /// Артикул блюда. Используется при вводе заказа с клавиатуры. + /// + 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 Barcodes { get; init; } = []; +} diff --git a/src/Domain/Entities/Order.cs b/src/Domain/Entities/Order.cs new file mode 100644 index 0000000..f5777fc --- /dev/null +++ b/src/Domain/Entities/Order.cs @@ -0,0 +1,37 @@ +namespace Domain.Entities; + +/// +/// Заказ (SendOrder). +/// +public sealed class Order +{ + private readonly List _items = []; + + public Guid Id { get; } + + public IReadOnlyCollection 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, + }); + } +} diff --git a/src/Domain/Entities/OrderItem.cs b/src/Domain/Entities/OrderItem.cs new file mode 100644 index 0000000..ac14388 --- /dev/null +++ b/src/Domain/Entities/OrderItem.cs @@ -0,0 +1,17 @@ +namespace Domain.Entities; + +/// +/// Позиция заказа (SendOrder / MenuItems). +/// +public sealed class OrderItem +{ + /// + /// Идентификатор блюда на сервере (). + /// + public required string MenuItemId { get; init; } + + /// + /// Количество. Для весовых блюд допускаются дробные значения. + /// + public decimal Quantity { get; init; } +}