PIbd-21_BatylkinaAO_MusoevD.../Canteen/CanteenBusinessLogic/BusinessLogics/GraphicLogic.cs

51 lines
1.6 KiB
C#
Raw Normal View History

2023-05-17 17:59:48 +04:00
using CanteenContracts.BindingModels;
using CanteenContracts.BusinessLogicsContracts;
using CanteenContracts.StoragesContracts;
using CanteenContracts.View;
using CanteenContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CanteenBusinessLogic.BusinessLogics
{
public class GraphicLogic : IGraphicLogic
{
private readonly IProductStorage _educationStorage;
public GraphicLogic(IProductStorage educationStorage)
{
_educationStorage = educationStorage;
}
public GraphicViewModel GetGraphicByPrice()
{
return new GraphicViewModel
{
Title = "Диаграмма выполненных заказов каждым поваром",
ColumnName = "Повара",
ValueName = "Количество заказов",
Data = GetEducation().Select(rec => new Tuple<string, double>(rec.ProductName, Convert.ToInt32(rec.Price))).ToList()
};
}
public GraphicViewModel GetGraphicByCount()
{
return new GraphicViewModel
{
Title = "Диаграмма продаваемости блюд",
ColumnName = "Блюда",
ValueName = "Количество блюд",
Data = GetEducation().Select(rec => new Tuple<string, double>(rec.ProductName, rec.Price)).ToList()
};
}
private List<ProductViewModel> GetEducation()
{
return _educationStorage.GetFullList();
}
}
}