public JsonResult SaveAndNext(AccidentSummaryViewModel model)
 {
     if (ModelState.IsValid)
     {
         UpdateAccidentRecordSummary(model);
         return Json(new { Success = true });
     }
     else
     {
         return ModelStateErrorsAsJson();
     }
 }
 public static object Create(long id, long companyId, string title, string reference, DateTime createdOn, bool isDeleted, bool isClosed)
 {
     var result = new AccidentSummaryViewModel
                      {
                          AccidentRecordId = id,
                          CompanyId = companyId,
                          Title = title,
                          Reference = reference,
                          CreatedOn = createdOn,
                          IsDeleted = isDeleted,
                          Status = isClosed ? AccidentRecordStatusEnum.Closed : AccidentRecordStatusEnum.Open
                      };
     return result;
 }
        public AccidentSummaryViewModel GetViewModel()
        {
            var viewModel = new AccidentSummaryViewModel();

            var accidentRecord = _accidentRecordService.GetByIdAndCompanyIdWithSite(_accidentRecordId,_companyId);

            if (accidentRecord != null)
            {
                viewModel.CompanyId = accidentRecord.CompanyId;
                viewModel.AccidentRecordId = accidentRecord.Id;
                viewModel.Title = accidentRecord.Title;
                viewModel.Reference = accidentRecord.Reference;
                viewModel.JurisdictionId = accidentRecord.Jurisdiction !=null ? accidentRecord.Jurisdiction.Id : default(long);
                viewModel.NextStepsVisible = accidentRecord.NextStepsAvailable;
            }

            return viewModel;
        }
        public ActionResult Save(AccidentSummaryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View("Index", model);
            }

            try
            {
                UpdateAccidentRecordSummary(model);
            }
            catch (ValidationException validationException)
            {
                ModelState.AddValidationErrors(validationException);
                return View("Index", model);
            }
            TempData["Notice"] = "Summary details successfully updated";
            return RedirectToAction("Index", "Summary", new { accidentRecordId = model.AccidentRecordId, companyId = CurrentUser.CompanyId });
        }
 private void UpdateAccidentRecordSummary(AccidentSummaryViewModel model)
 {
     _accidentRecordService.SaveAccidentRecordSummary(new SaveAccidentRecordSummaryRequest
                                                   {
                                                       CompanyId = CurrentUser.CompanyId,
                                                       AccidentRecordId = model.AccidentRecordId,
                                                       UserId = CurrentUser.UserId,
                                                       Title = model.Title,
                                                       Reference = model.Reference,
                                                       JurisdictionId = model.JurisdictionId
                                                   });
 }