예제 #1
0
        public ActionResult Edit(InspectionViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                var cars = _carService.GetCarsForUser(viewModel.UserId);
                ViewBag.DropListOfCarsToView  = GetCarsListView(cars, viewModel.CarId);
                ViewBag.DropListOfYearsToView = GetNextInspectionYearsListView(viewModel.NextInspectionYears);
                return(PartialView("_Edit", viewModel));
            }

            var inspection = new Inspection()
            {
                Id                  = viewModel.Id,
                CarId               = int.Parse(viewModel.SelectedCarId),
                Comments            = viewModel.Comments,
                InspectionDate      = viewModel.InspectionDate,
                NextInspectionYears = viewModel.NextInspectionYears
            };

            _inspectionService.EditInspection(inspection);
            return(Json(new { success = true }));
        }