Guarantor: Report logic was changed + might be needed to create property TotalAmount for PCs.

This commit is contained in:
Yuee Shiness 2023-04-07 20:45:34 +04:00
parent 9347ef10b4
commit c2baea1737
2 changed files with 4 additions and 10 deletions

View File

@ -5,6 +5,7 @@ using ComputerStoreContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -12,7 +13,6 @@ namespace ComputerStoreBusinessLogic.BusinessLogic
{ {
public class EmployeeReportLogic : IEmployeeReportLogic public class EmployeeReportLogic : IEmployeeReportLogic
{ {
//asd
private readonly IPCStorage _pcStorage; private readonly IPCStorage _pcStorage;
private readonly IProductStorage _productStorage; private readonly IProductStorage _productStorage;
private readonly IConsignmentStorage _consignmentStorage; private readonly IConsignmentStorage _consignmentStorage;
@ -37,20 +37,14 @@ namespace ComputerStoreBusinessLogic.BusinessLogic
{ {
PCName = pc.Name, PCName = pc.Name,
Components = new List<(string Component, int count)>(), Components = new List<(string Component, int count)>(),
Requests = new List<int>(), Request = requests.Where(x => x.RequestProduct.First(y => y.ID == pc.ID)).Select(x => x.ID)
TotalAmount = 0
}; };
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) foreach (var component in pc.PCComponents)
{ {
record.Components.Add(new(component.Value.Item1.Name, component.Value.Item2)); record.Components.Add(new(component.Value.Item1.Name, component.Value.Item2));
} }
record.TotalAmount = record.Requests.Count;
list.Add(record); list.Add(record);
} }
return list; return list;

View File

@ -11,6 +11,6 @@ namespace ComputerStoreContracts.ViewModels
public string PCName { get; set; } = string.Empty; public string PCName { get; set; } = string.Empty;
public int TotalAmount { get; set; } public int TotalAmount { get; set; }
public List<(string Component, int count)> Components { get; set; } = new List<(string Component, int count)> (); public List<(string Component, int count)> Components { get; set; } = new List<(string Component, int count)> ();
public List<int> Requests { get; set; } = new List<int> (); public int Request { get; set; }
} }
} }