часть реализации

This commit is contained in:
Максим Яковлев 2024-05-01 00:14:31 +04:00
parent 7d1e620601
commit 45d0720932
4 changed files with 34 additions and 3 deletions

View File

@ -1,5 +1,7 @@
using ServiceStationContracts.BindingModels; using ServiceStationContracts.BindingModels;
using ServiceStationContracts.BusinessLogicsContracts; using ServiceStationContracts.BusinessLogicsContracts;
using ServiceStationContracts.SearchModels;
using ServiceStationContracts.StoragesContracts;
using ServiceStationContracts.ViewModels; using ServiceStationContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,13 +13,40 @@ namespace ServiceStationBusinessLogic.BusinessLogics
{ {
public class ExecutorReportLogic : IExecutorReportLogic public class ExecutorReportLogic : IExecutorReportLogic
{ {
private readonly ITechnicalWorkStorage _techWorkStorage;
private readonly IRepairStorage _repairStorage;
public List<ReportWorksViewModel> GetWorks(List<int> Ids) public List<ReportWorksViewModel> GetWorks(List<int> Ids)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public List<ReportCarsViewModel> GetCars(ReportBindingModel model) public List<ReportCarsViewModel> GetCars(ReportBindingModel model)
{ {
throw new NotImplementedException(); List<ReportCarsViewModel> allList = new List<ReportCarsViewModel>();
List<TechnicalWorkViewModel> techWorkList = _techWorkStorage.GetFilteredList(new TechnicalWorkSearchModel
{
DateFrom = model.DateFrom,
DateTo = model.DateTo,
ExecutorId = model.ExecutorId,
});
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,
});
}
}
return allList;
} }
public void SaveComponentsToWordFile(ReportBindingModel model) public void SaveComponentsToWordFile(ReportBindingModel model)

View File

@ -10,6 +10,8 @@ namespace ServiceStationContracts.BindingModels
{ {
public string FileName { get; set; } = string.Empty; public string FileName { get; set; } = string.Empty;
public int ExecutorId { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }

View File

@ -12,7 +12,7 @@ namespace ServiceStationContracts.ViewModels
public string CarNumber { get; set; } = string.Empty; public string CarNumber { get; set; } = string.Empty;
public string CarBrand { get; set; } = string.Empty; public string CarBrand { get; set; } = string.Empty;
public string WorkType { get; set; } = string.Empty; public string WorkType { get; set; } = string.Empty;
public DateTime TechnicalWorkDate { get; set; } = DateTime.Now; public DateTime? TechnicalWorkDate { get; set; } = DateTime.Now;
public double TechnicalWorkPrice { get; set; } public double TechnicalWorkPrice { get; set; }
public string RepairName { get; set; } = string.Empty; public string RepairName { get; set; } = string.Empty;
public RepairStatus RepairStatus { get; set; } = RepairStatus.Неизвестен; public RepairStatus RepairStatus { get; set; } = RepairStatus.Неизвестен;

View File

@ -36,7 +36,7 @@ namespace ServiceStationDatabaseImplement.Implements
} }
using var context = new ServiceStationDatabase(); using var context = new ServiceStationDatabase();
if(model.DateTo.HasValue && model.DateTo.HasValue) if(model.DateTo.HasValue && model.DateTo.HasValue && model.ExecutorId.HasValue)
{ {
return context.TechnicalWorks return context.TechnicalWorks
.Include(x => x.Cars) .Include(x => x.Cars)