From 530526760f72eeaf0d5f190f85eb0c78b43f3749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Mon, 13 Mar 2023 23:01:00 +0400 Subject: [PATCH] fix --- ConfectionaryListImplement/ClientStorage.cs | 11 +++++++++-- ConfectioneryDatabaseImplement/Order.cs | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ConfectionaryListImplement/ClientStorage.cs b/ConfectionaryListImplement/ClientStorage.cs index 7540b52..7a43dca 100644 --- a/ConfectionaryListImplement/ClientStorage.cs +++ b/ConfectionaryListImplement/ClientStorage.cs @@ -66,8 +66,15 @@ namespace ConfectioneryListImplement public ClientViewModel? Insert(ClientBindingModel model) { - model.Id = _source.Clients.Count > 0 ? _source.Clients.Max(x => x.Id) + 1 : 1; - var res = Client.Create(model); + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var res = Client.Create(model); if (res != null) { _source.Clients.Add(res); diff --git a/ConfectioneryDatabaseImplement/Order.cs b/ConfectioneryDatabaseImplement/Order.cs index 3c815b4..080e04a 100644 --- a/ConfectioneryDatabaseImplement/Order.cs +++ b/ConfectioneryDatabaseImplement/Order.cs @@ -84,6 +84,7 @@ namespace ConfectioneryDatabaseImplement.Models return new() { PastryName = context.Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty, + ClientId = ClientId, ClientFIO = Client?.ClientFIO ?? string.Empty, PastryId = PastryId, Count = Count,