From 2a4d859356c760fcb2b00a13db61b09219a78105 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:26:13 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B0=D0=B2=D0=B8=D0=B6?= =?UTF-8?q?=D1=83=20linq?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfectionaryListImplement/ImplementerStorage.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) {