public JsonResult AddAction(VM_Action ViewAction) { if (ModelState.IsValid) { try { tblAction aAction = new tblAction(); aAction.ActionName = ViewAction.ActionName; aAction.ActionDisplayName = ViewAction.ActionDisplayName; aAction.ActionUrl = ViewAction.ActionUrl; aAction.ModuleId = ViewAction.ModuleId; aAction.IsInMenu = ViewAction.IsInMenu; aAction.IsView = ViewAction.IsView; aAction.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aAction.CreatedBy = SessionManger.LoggedInUser(Session); aAction.CreatedDateTime = DateTime.Now; aAction.EditedBy = null; aAction.EditedDateTime = null; unitOfWork.ActionRepository.Insert(aAction); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Action Added Successfully!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Fill Up all required filled" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(VM_Action viewAction) { if (ModelState.IsValid) { try { tblAction aAction = unitOfWork.ActionRepository.GetByID(viewAction.ActionId); aAction.ActionName = viewAction.ActionName; aAction.ActionDisplayName = viewAction.ActionDisplayName; aAction.ActionUrl = viewAction.ActionUrl; aAction.ModuleId = viewAction.ModuleId; aAction.IsInMenu = viewAction.IsInMenu; aAction.IsView = viewAction.IsView; aAction.EditedBy = SessionManger.LoggedInUser(Session); aAction.EditedDateTime = DateTime.Now; unitOfWork.ActionRepository.Update(aAction); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Action Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet)); } }