From 1d46ac36100dec57a43b717b475d53b0a0a134a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BA=20=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Tue, 28 Feb 2023 17:53:07 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BF=D1=80=D0=BE=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B8=D0=B7=D0=B4=D0=B5=D0=BB=D0=B8=D1=8F=20=D0=B2=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/OrderStorage.cs | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs index 0e684e3..1bb4b75 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs @@ -14,18 +14,16 @@ namespace BlacksmithWorkshopFileImplement.Implements { source = DataFileSingleton.GetInstance(); } + private OrderViewModel AddManufactureName (OrderViewModel model) + { + model.ManufactureName = source.Manufactures.SingleOrDefault(x => x.Id == model.ManufactureId)?.ManufactureName ?? string.Empty; + return model; + } public List GetFullList() { - List orderList = new(); - orderList = source.Orders - .Select(x => x.GetViewModel) + return source.Orders + .Select(x => AddManufactureName(x.GetViewModel)) .ToList(); - foreach (var order in orderList) - { - var manufactureName = source.Manufactures.SingleOrDefault(x => x.Id == order.ManufactureId)?.ManufactureName ?? string.Empty; - order.ManufactureName = manufactureName; - } - return orderList; } public List GetFilteredList(OrderSearchModel model) { @@ -33,17 +31,10 @@ namespace BlacksmithWorkshopFileImplement.Implements { return new(); } - List orderList = new(); - orderList = source.Orders + return source.Orders .Where(x => x.Id == model.Id) - .Select(x => x.GetViewModel) + .Select(x => AddManufactureName(x.GetViewModel)) .ToList(); - foreach (var order in orderList) - { - var manufactureName = source.Manufactures.SingleOrDefault(x => x.Id == order.ManufactureId)?.ManufactureName ?? string.Empty; - order.ManufactureName = manufactureName; - } - return orderList; } public OrderViewModel? GetElement(OrderSearchModel model) {