PIbd-21_BatylkinaAO_MusoevD.../Canteen/CanteenBusinessLogic/BusinessLogics/GraphicLogic.cs
2023-05-17 16:59:48 +03:00

51 lines
1.6 KiB
C#

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();
}
}
}