diff --git a/ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ExecutorReportLogic.cs b/ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ExecutorReportLogic.cs index 1f9248b..0ce599c 100644 --- a/ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ExecutorReportLogic.cs +++ b/ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ExecutorReportLogic.cs @@ -70,18 +70,22 @@ namespace ServiceStationBusinessLogic.BusinessLogics }; foreach(var work in works) { - var techWork = _techWorkStorage.GetElement(new TechnicalWorkSearchModel + if (work.TechnicalWorkId.HasValue) { - Id = work.TechnicalWorkId, - }); - foreach(var techCars in techWork.TechnicalWorkCars.Values) - { - if(techCars.Id == car.Id) + var techWork = _techWorkStorage.GetElement(new TechnicalWorkSearchModel { - rec.WorksInfo.Add(new(work.WorkName, work.WorkPrice)); - price += work.WorkPrice; + Id = work.TechnicalWorkId, + }); + foreach (var techCars in techWork.TechnicalWorkCars.Values) + { + if (techCars.Id == car.Id) + { + rec.WorksInfo.Add(new(work.WorkName, work.WorkPrice)); + price += work.WorkPrice; + } } } + } rec.FullPrice = price; allList.Add(rec); diff --git a/ServiceStation/ServiceStationExecutorApp/Controllers/HomeController.cs b/ServiceStation/ServiceStationExecutorApp/Controllers/HomeController.cs index a5661e0..9dec6df 100644 --- a/ServiceStation/ServiceStationExecutorApp/Controllers/HomeController.cs +++ b/ServiceStation/ServiceStationExecutorApp/Controllers/HomeController.cs @@ -1,4 +1,5 @@ -using DocumentFormat.OpenXml.Wordprocessing; +using DocumentFormat.OpenXml.Drawing; +using DocumentFormat.OpenXml.Wordprocessing; using Microsoft.AspNetCore.Mvc; using ServiceStationContracts.BindingModels; using ServiceStationContracts.BusinessLogicsContracts; @@ -121,6 +122,18 @@ namespace ServiceStationExecutorApp.Controllers return View(APIExecutor.GetRequest>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}")); } [HttpGet] + public CarViewModel? GetCar(int carId) + { + if (APIExecutor.Executor == null) + { + throw new Exception("Необходима авторизация"); + } + var result = APIExecutor.GetRequest($"api/main/getcar?carId={carId}"); + if (result == null) return null; + + return result; + } + [HttpGet] public Tuple? GetDefect(int defectId) { if(APIExecutor.Executor == null) @@ -300,10 +313,10 @@ namespace ServiceStationExecutorApp.Controllers return RedirectToAction("Enter"); } ViewBag.TechnicalWorks = APIExecutor.GetRequest>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}"); - return View(); + return View(APIExecutor.GetRequest>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}")); } [HttpPost] - public void UpdateTechnicalWork(int technicalWork, string TechnicalWorkType, double TechnicalWorkPrice) + public void UpdateTechnicalWork(int technicalWork, string TechnicalWorkType, double TechnicalWorkPrice, int[] car) { if (APIExecutor.Executor == null) { @@ -324,6 +337,10 @@ namespace ServiceStationExecutorApp.Controllers ExecutorId = APIExecutor.Executor.Id, WorkPrice = TechnicalWorkPrice, }); + APIExecutor.PostRequest("api/main/addcartotechnicalwork", Tuple.Create( + new TechnicalWorkSearchModel() { Id = technicalWork }, + car + )); Response.Redirect("ListTechnicalWorks"); } public IActionResult CreateCar() @@ -382,10 +399,10 @@ namespace ServiceStationExecutorApp.Controllers { return RedirectToAction("Enter"); } - return View(); + return View(APIExecutor.GetRequest>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}")); } [HttpPost] - public void CreateTechnicalWork(string WorkType, double WorkPrice) + public void CreateTechnicalWork(string WorkType, double WorkPrice, int[] car) { if (APIExecutor.Executor == null) { @@ -398,6 +415,10 @@ namespace ServiceStationExecutorApp.Controllers WorkPrice = WorkPrice, DateStartWork = DateTime.Now }); + APIExecutor.PostRequest("api/main/addcartotechnicalwork", Tuple.Create( + new TechnicalWorkSearchModel() { WorkType = WorkType }, + car + )); Response.Redirect("ListTechnicalWorks"); } public IActionResult BindingTechnicalWorkToWork() @@ -503,7 +524,7 @@ namespace ServiceStationExecutorApp.Controllers } APIExecutor.PostRequest("api/report/createexecutorreporttopdf", new PdfReportBindingModel { - FileName = Directory.GetCurrentDirectory() + "\\Reports\\pdffile.pdf", + FileName = Directory.GetCurrentDirectory().Replace("ServiceStationExecutorApp", "ServiceStationRestApi") + "\\Reports\\pdffile.pdf", DateFrom = dateFrom, DateTo = dateTo, ExecutorId = APIExecutor.Executor.Id, diff --git a/ServiceStation/ServiceStationExecutorApp/Views/Home/CreateDefect.cshtml b/ServiceStation/ServiceStationExecutorApp/Views/Home/CreateDefect.cshtml index c66b4f8..d74b7b2 100644 --- a/ServiceStation/ServiceStationExecutorApp/Views/Home/CreateDefect.cshtml +++ b/ServiceStation/ServiceStationExecutorApp/Views/Home/CreateDefect.cshtml @@ -1,10 +1,10 @@ @using ServiceStationContracts.ViewModels - +@model List @{ ViewData["Title"] = "CreateDefect"; } -@model List +
diff --git a/ServiceStation/ServiceStationExecutorApp/Views/Home/CreateTechnicalWork.cshtml b/ServiceStation/ServiceStationExecutorApp/Views/Home/CreateTechnicalWork.cshtml index 832420c..ea354d4 100644 --- a/ServiceStation/ServiceStationExecutorApp/Views/Home/CreateTechnicalWork.cshtml +++ b/ServiceStation/ServiceStationExecutorApp/Views/Home/CreateTechnicalWork.cshtml @@ -1,6 +1,5 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ +@using ServiceStationContracts.ViewModels +@model List @{ ViewData["Title"] = "CreateTechnicalWork"; } @@ -14,6 +13,29 @@
+ + + + + + + + + + @foreach (var car in Model) + { + + + + + + } + +
Номер машиныМарка машины
+
+ +
+
@Html.DisplayFor(modelItem => car.CarNumber)@Html.DisplayFor(modelItem => car.CarBrand)

diff --git a/ServiceStation/ServiceStationExecutorApp/Views/Home/ListTechnicalWorks.cshtml b/ServiceStation/ServiceStationExecutorApp/Views/Home/ListTechnicalWorks.cshtml index 90795fe..6395c86 100644 --- a/ServiceStation/ServiceStationExecutorApp/Views/Home/ListTechnicalWorks.cshtml +++ b/ServiceStation/ServiceStationExecutorApp/Views/Home/ListTechnicalWorks.cshtml @@ -49,8 +49,6 @@   Изменить   - Добавить машину -   Удалить
diff --git a/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateCar.cshtml b/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateCar.cshtml index f7f6cfa..457df97 100644 --- a/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateCar.cshtml +++ b/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateCar.cshtml @@ -25,4 +25,27 @@ -
\ No newline at end of file + +@section Scripts +{ + +} \ No newline at end of file diff --git a/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateDefect.cshtml b/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateDefect.cshtml index 11cb5ba..97cec41 100644 --- a/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateDefect.cshtml +++ b/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateDefect.cshtml @@ -13,11 +13,11 @@
- +
- +
Уже привязанные машины
@@ -74,6 +74,8 @@ url: "/Home/GetDefect", data: { defectId: defect }, success: function (result) { + $('#defectType').val(result.item1.defectType); + $('#defectPrice').val(result.item1.defectPrice); $('#table-elements').html(result.item2); } }); diff --git a/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateTechnicalWork.cshtml b/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateTechnicalWork.cshtml index 4222edb..69dfb92 100644 --- a/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateTechnicalWork.cshtml +++ b/ServiceStation/ServiceStationExecutorApp/Views/Home/UpdateTechnicalWork.cshtml @@ -1,6 +1,6 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ +@using ServiceStationContracts.ViewModels + +@model List @{ ViewData["Title"] = "UpdateTechnicalWork"; } @@ -13,12 +13,13 @@
- +
- +
+
Уже привязанные машины
@@ -30,6 +31,30 @@ @* полученные машины *@
+
Изменить машины
+ + + + + + + + + + @foreach (var car in Model) + { + + + + + + } + +
Номер машиныМарка машины
+
+ +
+
@Html.DisplayFor(modelItem => car.CarNumber)@Html.DisplayFor(modelItem => car.CarBrand)

@@ -49,7 +74,8 @@ url: "/Home/GetTechnicalWork", data: { technicalWorkId: technicalWork }, success: function (result) { - $('#technicalWorkType').val(result.item1.WorkType); + $('#worktype').val(result.item1.workType); + $('#workPrice').val(result.item1.workPrice); $('#table-elements').html(result.item2); } }); diff --git a/ServiceStation/ServiceStationRestApi/Controllers/MainController.cs b/ServiceStation/ServiceStationRestApi/Controllers/MainController.cs index 91b20b4..455b00c 100644 --- a/ServiceStation/ServiceStationRestApi/Controllers/MainController.cs +++ b/ServiceStation/ServiceStationRestApi/Controllers/MainController.cs @@ -238,6 +238,19 @@ namespace ServiceStationRestApi.Controllers } } [HttpGet] + public CarViewModel? GetCar(int carId) + { + try + { + return _clogic.ReadElement(new CarSearchModel { Id = carId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения машины по id={Id}", carId); + throw; + } + } + [HttpGet] public Tuple>>? GetDefect(int defectId) { try diff --git a/ServiceStation/ServiceStationRestApi/Reports/pdffile.pdf b/ServiceStation/ServiceStationRestApi/Reports/pdffile.pdf index 8b475b9..47b8c70 100644 Binary files a/ServiceStation/ServiceStationRestApi/Reports/pdffile.pdf and b/ServiceStation/ServiceStationRestApi/Reports/pdffile.pdf differ