public ActionResult SaveInspection(VehicleInspectionViewModel model, FormCollection form) { if (!caSession.AuthoriseSession()) { return Redirect((string)Session["ErrorUrl"]); } var tickedInspections = form.AllKeys.Where(m=> m.StartsWith("Inspection_") && !string.IsNullOrEmpty(form[m]) && form[m].Contains("true")).Select(x=> int.Parse(x.Replace("Inspection_",string.Empty))).ToList(); model.TenantId = CurrentTenantId; var inspection = Mapper.Map(model, new VehicleInspection()); _inspectionService.SaveInspection(inspection, CurrentUserId, tickedInspections); return RedirectToAction("Index"); }
public ActionResult Edit(int? id, int vehicleId=0) { if (!caSession.AuthoriseSession()) { return Redirect((string)Session["ErrorUrl"]); } var model = new VehicleInspectionViewModel { MarketVehicleId = vehicleId }; if (id.HasValue && id > 0) { model = _inspectionService.GetVehicleInspectionById(id.Value); if (model.Id < 1) return HttpNotFound(); } model.CheckList = _inspectionService.GetAllInspectionCheckLists(CurrentTenantId); model.AllEmployees = _inspectionService.GetAllVehicleDrivers(CurrentTenantId); model.AllVehicles = _marketServices.GetAllValidMarketVehicles(CurrentTenantId).MarketVehicles; return View("_CreateEdit", model); }