73 lines
2.5 KiB
C#
73 lines
2.5 KiB
C#
using CarCenterContracts.BindingModels;
|
|
using CarCenterContracts.BusinessLogicsContracts;
|
|
using CarCenterContracts.StoragesContracts;
|
|
using CarCenterContracts.ViewModels;
|
|
using CarCenterBusinessLogic.OfficePackage;
|
|
using CarCenterBusinessLogic.OfficePackage.HelperModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CarCenterBusinessLogic.BusinessLogics
|
|
{
|
|
public class ReportLogicAdministrator : IReportLogicAdministrator
|
|
{
|
|
private readonly ICarStorage _carStorage;
|
|
private readonly AbstractSaveToExcelAdministrator _saveToExcel;
|
|
private readonly AbstractSaveToWordAdministrator _saveToWord;
|
|
private readonly AbstractSaveToPdfAdministrator _saveToPdf;
|
|
|
|
public ReportLogicAdministrator(ICarStorage carStorage,
|
|
AbstractSaveToExcelAdministrator saveToExcel, AbstractSaveToWordAdministrator saveToWord, AbstractSaveToPdfAdministrator saveToPdf)
|
|
{
|
|
_carStorage = carStorage;
|
|
_saveToExcel = saveToExcel;
|
|
_saveToWord = saveToWord;
|
|
_saveToPdf = saveToPdf;
|
|
}
|
|
public void SavePreSaleWorksToExcelFile(ReportPreSaleWorkCarBindingModel model)
|
|
{
|
|
_saveToExcel.CreateReport(new ExcelInfoAdministrator
|
|
{
|
|
FileName = model.FileName,
|
|
Title = "Список предпродажных работ по машинам",
|
|
PreSaleWorkCars = GetPreSaleWorkCars(model)
|
|
});
|
|
}
|
|
|
|
public void SavePreSaleWorksToWordFile(ReportPreSaleWorkCarBindingModel model)
|
|
{
|
|
_saveToWord.CreateDoc(new WordInfoAdministrator
|
|
{
|
|
FileName = model.FileName,
|
|
Title = "Список предпродажных работ по машинам",
|
|
PreSaleWorkCars = GetPreSaleWorkCars(model)
|
|
});
|
|
}
|
|
|
|
public List<ReportPreSaleWorkCarViewModel> GetPreSaleWorkCars(ReportPreSaleWorkCarBindingModel model)
|
|
{
|
|
return _carStorage.GetReportCarPreSaleWorksList(new() { carsIds = model.Cars });
|
|
}
|
|
public List<ReportEquipmentsEmployeesViewModel> GetEquipmentsEmployees(ReportEquipmentsEmployeesBindingModel model)
|
|
{
|
|
return _carStorage.GetReportEquipmentsEmployees(new() { DateFrom = model.DateFrom, DateTo = model.DateTo });
|
|
}
|
|
|
|
public void SaveCarsToPdfFile(ReportEquipmentsEmployeesBindingModel model)
|
|
{
|
|
_saveToPdf.CreateDoc(new PdfInfo
|
|
{
|
|
FileName = model.FileName,
|
|
Title = "Список машин",
|
|
DateFrom = model.DateFrom!,
|
|
DateTo = model.DateTo!,
|
|
ReportEquipmentsEmployees = GetEquipmentsEmployees(model)
|
|
});
|
|
|
|
}
|
|
}
|
|
}
|