public IActionResult SaveDispatch(DispatchModel model, string create) { if (!ModelState.IsValid) { return(View("CreateDispatch", model)); } string message = string.Empty; long id = 0; try { if (create == "Finalize Dispatch") { model.IsFinalize = true; id = _service.Update(model); } else if (model.DispatchId > 0) { id = _service.Update(model); } else { id = _service.Insert(model); } } catch (Exception ex) { message = CommonHelper.GetErrorMessage(ex); } if (!string.IsNullOrEmpty(message)) { ViewBag.openPopup = CommonHelper.ShowAlertMessage(message); return(View("CreateDispatch", model)); } if (create == "Save & Continue") { return(RedirectToAction("Edit", "Dispatch", new { id })); } return(RedirectToAction("Index")); }