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