From 2d5dccd197e14937b7241dd8cc03b9e43eff4522 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 9 Apr 2023 10:15:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8E=20=D1=8D=D0=BB=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=20(=D0=9A=D0=BB=D0=B8=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/ClientStorage.cs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/ClientStorage.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/ClientStorage.cs index 4b8cc2a..50b0681 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/ClientStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/ClientStorage.cs @@ -28,27 +28,37 @@ namespace FurnitureAssemblyDatabaseImplement.Implements public ClientViewModel? GetElement(ClientSearchModel model) { - if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue) + if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.Password)) { return null; } using var context = new FurnitureAssemblyDatabase(); - return context.Clients - .FirstOrDefault(x => - (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email) || - (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; + if (model.Id.HasValue) + { + return context.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; + } + if (model.Email != null && model.Password != null) + { + return context.Clients + .FirstOrDefault(x => x.Email.Equals(model.Email) && x.Password.Equals(model.Password)) + ?.GetViewModel; + } + if (model.Email != null) + { + return context.Clients.FirstOrDefault(x => x.Email.Equals(model.Email))?.GetViewModel; + } + return null; } public List GetFilteredList(ClientSearchModel model) { - if (string.IsNullOrEmpty(model.Email) || string.IsNullOrEmpty(model.Password)) + if (string.IsNullOrEmpty(model.Email)) { return new(); } using var context = new FurnitureAssemblyDatabase(); return context.Clients - .Where(x => x.Email.Equals(model.Email) && x.Password.Equals(model.Password)) + .Where(x => x.Email.Equals(model.Email)) .Select(x => x.GetViewModel) .ToList(); }