public ActionResult Update(FiscalYear obj) { if (ModelState.IsValid) { try { string flag = "u"; if (obj.Id < 1) { flag = "i"; } var result = iFiscalYear.Update(obj, flag); return(Json(new { ErrorCode = result.ErrorCode, Message = result.Msg, Id = result.Id, JsonRequestBehavior.AllowGet })); } catch (Exception ex) { return(Json(new { ErrorCode = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } Response.TrySkipIisCustomErrors = true; string messages = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); return(Json(new { ErrorCode = 1, Message = messages }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(FiscalYearModel model) { try { if (ModelState.IsValid) { model.UpdatedDate = DateTime.Now; model.StartDateNp = ""; model.EndDateNp = ""; fiscalService.Update(model); TempData["Success"] = $"{model.FiscalYearName} is updated !"; return(RedirectToAction("Index")); } return(View(@"~\Views\Configuration\FiscalYear\Edit.cshtml", model)); } catch (Exception e) { TempData["Danger"] = $"Oppps something went wrong {e.Message}"; throw; } }