135 lines
4.5 KiB
C#
135 lines
4.5 KiB
C#
using ServiceStationContracts.BindingModels;
|
|
using ServiceStationContracts.BusinessLogicsContracts;
|
|
using ServiceStationContracts.SearchModels;
|
|
using ServiceStationContracts.StoragesContracts;
|
|
using ServiceStationContracts.ViewModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ServiceStationBusinessLogic.BusinessLogics
|
|
{
|
|
public class ExecutorReportLogic : IExecutorReportLogic
|
|
{
|
|
|
|
private readonly ITechnicalWorkStorage _techWorkStorage;
|
|
private readonly IRepairStorage _repairStorage;
|
|
private readonly IWorkStorage _workStorage;
|
|
private readonly ICarStorage _carStorage;
|
|
|
|
public ExecutorReportLogic(ITechnicalWorkStorage technicalWorkStorage, IRepairStorage repairStorage, IWorkStorage workStorage, ICarStorage carStorage)
|
|
{
|
|
_techWorkStorage = technicalWorkStorage;
|
|
_repairStorage = repairStorage;
|
|
_workStorage = workStorage;
|
|
_carStorage = carStorage;
|
|
}
|
|
|
|
public List<ReportWorksViewModel> GetWorks(List<int> Ids)
|
|
{
|
|
if(Ids == null) return new List<ReportWorksViewModel>();
|
|
|
|
List<ReportWorksViewModel> allList = new List<ReportWorksViewModel>();
|
|
|
|
var works = _workStorage.GetFullList();
|
|
List<CarViewModel> cars = new List<CarViewModel>();
|
|
foreach (var carId in Ids)
|
|
{
|
|
var car = _carStorage.GetElement(new CarSearchModel
|
|
{
|
|
Id = carId,
|
|
});
|
|
if(car != null)
|
|
{
|
|
cars.Add(car);
|
|
}
|
|
}
|
|
|
|
foreach(var car in cars)
|
|
{
|
|
var rec = new ReportWorksViewModel
|
|
{
|
|
CarNumber = car.CarNumber,
|
|
WorksInfo = new List<(string, double)>()
|
|
};
|
|
foreach(var work in works)
|
|
{
|
|
var techWork = _techWorkStorage.GetElement(new TechnicalWorkSearchModel
|
|
{
|
|
Id = work.TechnicalWorkId,
|
|
});
|
|
foreach(var techCars in techWork.TechnicalWorkCars.Values)
|
|
{
|
|
if(techCars.Id == car.Id)
|
|
{
|
|
rec.WorksInfo.Add(new(work.WorkName, work.WorkPrice));
|
|
}
|
|
}
|
|
}
|
|
allList.Add(rec);
|
|
}
|
|
return allList;
|
|
}
|
|
public List<ReportCarsViewModel> GetCars(ReportBindingModel model)
|
|
{
|
|
List<ReportCarsViewModel> allList = new List<ReportCarsViewModel>();
|
|
|
|
List<TechnicalWorkViewModel> techWorkList = _techWorkStorage.GetFilteredList(new TechnicalWorkSearchModel
|
|
{
|
|
DateFrom = model.DateFrom,
|
|
DateTo = model.DateTo,
|
|
});
|
|
|
|
foreach(var techWork in techWorkList)
|
|
{
|
|
foreach(var car in techWork.TechnicalWorkCars.Values)
|
|
{
|
|
allList.Add(new ReportCarsViewModel
|
|
{
|
|
CarNumber = car.CarNumber,
|
|
CarBrand = car.CarBrand,
|
|
WorkType = techWork.WorkType,
|
|
TechnicalWorkDate = techWork.DateStartWork,
|
|
TechnicalWorkPrice = techWork.WorkPrice,
|
|
});
|
|
}
|
|
}
|
|
|
|
List<RepairViewModel> repairList = _repairStorage.GetFilteredList(new RepairSearchModel
|
|
{
|
|
DateFrom = model.DateFrom,
|
|
DateTo = model.DateTo,
|
|
});
|
|
|
|
foreach(var repair in repairList)
|
|
{
|
|
allList.Add(new ReportCarsViewModel
|
|
{
|
|
RepairName = repair.RepairName,
|
|
RepairStartDate = repair.RepairStartDate,
|
|
RepairPrice = repair.RepairPrice,
|
|
});
|
|
}
|
|
|
|
return allList;
|
|
}
|
|
|
|
public void SaveComponentsToWordFile(ReportBindingModel model)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void SaveRepairComponentToExcelFile(ReportBindingModel model)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|