доработка метода получения отчета по заявкам

This commit is contained in:
Мк Игорь 2023-04-07 20:52:26 +04:00
parent 0a00c532db
commit 148abdfb8e

View File

@ -59,7 +59,7 @@ namespace CarServiceDatabase.Implements
.Select(w => new ReportWorkWithRequestsViewModel() .Select(w => new ReportWorkWithRequestsViewModel()
{ {
WorkName = w.Name, WorkName = w.Name,
RepairRequests = GetRepairRequestsByWork(model) RepairRequests = GetRepairRequestsByWork(context, new() { Id = w.Id })
}) })
.ToList(); .ToList();
} }
@ -68,9 +68,8 @@ namespace CarServiceDatabase.Implements
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
private List<ReportRepairRequestViewModel> GetRepairRequestsByWork(WorkSearchModel model) private static List<ReportRepairRequestViewModel> GetRepairRequestsByWork(CarServiceDbContext context, WorkSearchModel model)
{ {
using var context = new CarServiceDbContext();
return context.WorksInRequest return context.WorksInRequest
.Include(wir => wir.RepairRequest) .Include(wir => wir.RepairRequest)
.ThenInclude(rr => rr.Vehicle) .ThenInclude(rr => rr.Vehicle)