From c2baea1737b17a5283604e487f0598d4ed9a500b Mon Sep 17 00:00:00 2001 From: Yuee Shiness Date: Fri, 7 Apr 2023 20:45:34 +0400 Subject: [PATCH] Guarantor: Report logic was changed + might be needed to create property TotalAmount for PCs. --- .../BusinessLogic/EmployeeReportLogic.cs | 12 +++--------- .../ViewModels/ReportRequestComponentViewModel.cs | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs b/ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs index 7717786..e6c737b 100644 --- a/ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs +++ b/ComputerStoreBusinessLogic/BusinessLogic/EmployeeReportLogic.cs @@ -5,14 +5,14 @@ using ComputerStoreContracts.ViewModels; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace ComputerStoreBusinessLogic.BusinessLogic { public class EmployeeReportLogic : IEmployeeReportLogic - { - //asd + { private readonly IPCStorage _pcStorage; private readonly IProductStorage _productStorage; private readonly IConsignmentStorage _consignmentStorage; @@ -37,20 +37,14 @@ namespace ComputerStoreBusinessLogic.BusinessLogic { PCName = pc.Name, Components = new List<(string Component, int count)>(), - Requests = new List(), - TotalAmount = 0 + Request = requests.Where(x => x.RequestProduct.First(y => y.ID == pc.ID)).Select(x => x.ID) }; - foreach (var request in requests) - { - record.Requests.Add(request.RequestProducts.FirstOrDefault(x => x.ID == pc.ID).Select(x => x.ID)); - } foreach (var component in pc.PCComponents) { record.Components.Add(new(component.Value.Item1.Name, component.Value.Item2)); } - record.TotalAmount = record.Requests.Count; list.Add(record); } return list; diff --git a/ComputerStoreContracts/ViewModels/ReportRequestComponentViewModel.cs b/ComputerStoreContracts/ViewModels/ReportRequestComponentViewModel.cs index 22c1b4b..d5b8266 100644 --- a/ComputerStoreContracts/ViewModels/ReportRequestComponentViewModel.cs +++ b/ComputerStoreContracts/ViewModels/ReportRequestComponentViewModel.cs @@ -11,6 +11,6 @@ namespace ComputerStoreContracts.ViewModels public string PCName { get; set; } = string.Empty; public int TotalAmount { get; set; } public List<(string Component, int count)> Components { get; set; } = new List<(string Component, int count)> (); - public List Requests { get; set; } = new List (); + public int Request { get; set; } } }