Доработка
This commit is contained in:
parent
6d7b87aee9
commit
42fcf4bce6
@ -5,6 +5,8 @@ using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||
using AutomobilePlantContracts.SearchModel;
|
||||
using AutomobilePlantContracts.StoragesContracts;
|
||||
using AutomobilePlantContracts.ViewModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -178,27 +180,9 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
||||
public List<ReportAllOrdersViewModel> GetOrdersAll()
|
||||
{
|
||||
var orders = _orderStorage.GetFullList().OrderBy(x => x.DateCreate).ToList();
|
||||
Dictionary<DateTime,(int, double)> dictionaryOrders = new Dictionary<DateTime,(int,double)>();
|
||||
List< ReportAllOrdersViewModel> list = new List<ReportAllOrdersViewModel>();
|
||||
if(orders.Count == 0) return list;
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
if (dictionaryOrders.ContainsKey(order.DateCreate.Date))
|
||||
{
|
||||
dictionaryOrders[order.DateCreate.Date] = (dictionaryOrders[order.DateCreate.Date].Item1 + 1, dictionaryOrders[order.DateCreate.Date].Item2 + order.Sum);
|
||||
}else
|
||||
dictionaryOrders.Add(order.DateCreate.Date, (1, order.Sum));
|
||||
}
|
||||
foreach(var order in dictionaryOrders)
|
||||
{
|
||||
list.Add(new ReportAllOrdersViewModel
|
||||
{
|
||||
DateCreate = order.Key,
|
||||
Count = order.Value.Item1,
|
||||
Sum = order.Value.Item2
|
||||
}) ;
|
||||
}
|
||||
var list = orders.GroupBy(x => x.DateCreate.Date)
|
||||
.Select(g => new ReportAllOrdersViewModel { DateCreate=g.Key, Count = g.Count(), Sum = g.Sum(g=>g.Sum) })
|
||||
.ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user