diff --git a/CarService/CarServiceContracts/ViewModels/RepairRequestViewModel.cs b/CarService/CarServiceContracts/ViewModels/RepairRequestViewModel.cs index ec69250..008acf5 100644 --- a/CarService/CarServiceContracts/ViewModels/RepairRequestViewModel.cs +++ b/CarService/CarServiceContracts/ViewModels/RepairRequestViewModel.cs @@ -10,5 +10,9 @@ namespace CarServiceContracts.ViewModels [DisplayName("Дата создания")] public DateTime DateCreated { get; set; } = DateTime.Now; public int VehicleId { get; set; } + public string VehicleName { get; set; } = string.Empty; + public string VehiclePlate { get; set; } = string.Empty; + public string VehicleVIN { get; set; } = string.Empty; + public string CustomerName { get; set; } = string.Empty; } } diff --git a/CarService/CarServiceDatabase/Implements/RepairRequestStorage.cs b/CarService/CarServiceDatabase/Implements/RepairRequestStorage.cs index f54c511..489e044 100644 --- a/CarService/CarServiceDatabase/Implements/RepairRequestStorage.cs +++ b/CarService/CarServiceDatabase/Implements/RepairRequestStorage.cs @@ -13,6 +13,8 @@ namespace CarServiceDatabase.Implements { using var context = new CarServiceDbContext(); return context.RepairRequests + .Include(x => x.Vehicle) + .ThenInclude(x => x.Customer) .Select(x => x.GetViewModel) .ToList(); } diff --git a/CarService/CarServiceDatabase/Models/RepairRequest.cs b/CarService/CarServiceDatabase/Models/RepairRequest.cs index a7ab094..22789ae 100644 --- a/CarService/CarServiceDatabase/Models/RepairRequest.cs +++ b/CarService/CarServiceDatabase/Models/RepairRequest.cs @@ -49,7 +49,11 @@ namespace CarServiceDatabase.Models { Id = Id, DateCreated = DateCreated, - VehicleId = VehicleId + VehicleId = VehicleId, + VehicleName = Vehicle.Name, + VehiclePlate = Vehicle.Plate, + VehicleVIN = Vehicle.VIN ?? "Отсутствует", + CustomerName = Vehicle.Customer.Name + " " + Vehicle.Customer.Surname }; } } diff --git a/CarService/CarServiceWebApp/Controllers/HomeController.cs b/CarService/CarServiceWebApp/Controllers/HomeController.cs index 7dd39f3..ca432ef 100644 --- a/CarService/CarServiceWebApp/Controllers/HomeController.cs +++ b/CarService/CarServiceWebApp/Controllers/HomeController.cs @@ -14,13 +14,15 @@ namespace CarServiceWebApp.Controllers private readonly IWorkLogic _workLogic; private readonly IWorkerLogic _workerLogic; private readonly IItemLogic _itemLogic; + private readonly IRepairRequestLogic _repairRequestLogic; - public HomeController(ILogger logger, IWorkLogic workLogic, IWorkerLogic workerLogic, IItemLogic itemLogic) + public HomeController(ILogger logger, IWorkLogic workLogic, IWorkerLogic workerLogic, IItemLogic itemLogic, IRepairRequestLogic repairRequestLogic) { _logger = logger; _workLogic = workLogic; _workerLogic = workerLogic; _itemLogic = itemLogic; + _repairRequestLogic = repairRequestLogic; } /// /// Главная страница @@ -247,6 +249,21 @@ namespace CarServiceWebApp.Controllers } return Redirect("~/Home/Items"); } + [HttpGet] + public IActionResult RepairRequests() + { + if (CurrentUser.UserId < 1) + { + return Redirect("~/Home/Index"); + } + var RepairRequests = _repairRequestLogic.ReadList(null); + ViewBag.RepairRequests = RepairRequests; + if (RepairRequests?.Count == 0) + { + ViewBag.Exception = "Пока нет заявок"; + } + return View(); + } /// /// Вывод ошибок /// diff --git a/CarService/CarServiceWebApp/Program.cs b/CarService/CarServiceWebApp/Program.cs index 187d902..1836894 100644 --- a/CarService/CarServiceWebApp/Program.cs +++ b/CarService/CarServiceWebApp/Program.cs @@ -15,6 +15,8 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); var app = builder.Build(); diff --git a/CarService/CarServiceWebApp/Views/Home/RepairRequests.cshtml b/CarService/CarServiceWebApp/Views/Home/RepairRequests.cshtml new file mode 100644 index 0000000..c0263f4 --- /dev/null +++ b/CarService/CarServiceWebApp/Views/Home/RepairRequests.cshtml @@ -0,0 +1,36 @@ +@{ + ViewData["Title"] = "Заявки на ремонт"; +} + +
+

Заявки

+ @if (ViewBag.RepairRequests.Count != 0) + { +
+ + + + + + + + + + + + @foreach (var request in ViewBag.RepairRequests) + { + + + + + + + + } + +
Дата созданияТранспортное средствоVIN-номерГос. номерКлиент
@request.DateCreated@request.VehicleName@request.VehicleVIN@request.VehiclePlate@request.CustomerName
+
+ } +
@ViewBag.Exception
+
\ No newline at end of file diff --git a/CarService/CarServiceWebApp/Views/Shared/_Layout.cshtml b/CarService/CarServiceWebApp/Views/Shared/_Layout.cshtml index 7e55390..673ce29 100644 --- a/CarService/CarServiceWebApp/Views/Shared/_Layout.cshtml +++ b/CarService/CarServiceWebApp/Views/Shared/_Layout.cshtml @@ -23,7 +23,7 @@ Работы