diff --git a/ConfectionaryListImplement/ClientStorage.cs b/ConfectionaryListImplement/ClientStorage.cs index 7540b52..7a609c9 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 client in _source.Clients) + { + if (model.Id <= client.Id) + { + model.Id = client.Id + 1; + } + } + var res = Client.Create(model); if (res != null) { _source.Clients.Add(res); diff --git a/ConfectionaryListImplement/ImplementerStorage.cs b/ConfectionaryListImplement/ImplementerStorage.cs index 7dbf4ab..12fb158 100644 --- a/ConfectionaryListImplement/ImplementerStorage.cs +++ b/ConfectionaryListImplement/ImplementerStorage.cs @@ -82,7 +82,14 @@ namespace ConfectioneryListImplement public ImplementerViewModel? Insert(ImplementerBindingModel model) { - model.Id = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.Id) + 1 : 1; + model.Id = 1; + foreach (var implementer in _source.Implementers) + { + if (model.Id <= implementer.Id) + { + model.Id = implementer.Id + 1; + } + } var res = Implementer.Create(model); if (res != null) { diff --git a/ConfectioneryDatabaseImplement/Order.cs b/ConfectioneryDatabaseImplement/Order.cs index c9b44a6..88d3fa1 100644 --- a/ConfectioneryDatabaseImplement/Order.cs +++ b/ConfectioneryDatabaseImplement/Order.cs @@ -89,7 +89,9 @@ namespace ConfectioneryDatabaseImplement.Models return new() { PastryName = context.Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty, + ClientId = ClientId, ClientFIO = Client?.ClientFIO ?? string.Empty, + ImplementerId = ImplementerId, ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty, PastryId = PastryId, Count = Count,