public ActionResult Create(InspectionModel inspectionModel) { try { InspectionDetail inspectionDetail = new InspectionDetail { ID = inspectionModel.ID, DateOfInsp = inspectionModel.DateOfInsp, PurposeOfInsp = inspectionModel.PurposeOfInsp, InspectorName = inspectionModel.InspectorName, InspectorDesg = inspectionModel.InspectorDesg, InspectorAdrs = inspectionModel.InspectorAdrs, Report = inspectionModel.Report }; if (ModelState.IsValid) { if (inspectionDetail.ID > 0) { inspectionRepository.UpdateInspectionDetail(inspectionDetail); } else { inspectionRepository.InsertInspectionDetail(inspectionDetail); } } else { return(View(inspectionModel)); } return(RedirectToAction("Index")); } catch (Exception) { return(View(inspectionModel)); } }