private bool CustomSaveOnEdit(T_PositionLevel t_positionlevel, out bool customsave_hasissues, string command = "") { var result = false; customsave_hasissues = false; return(result); }
public ActionResult DeleteBulk(long[] ids, string UrlReferrer) { if (User != null && (!((CustomPrincipal)User).CanUseVerb("BulkDelete", "T_PositionLevel", User) || !User.CanDelete("T_PositionLevel"))) { return(RedirectToAction("Index", "Error")); } bool customdelete_hasissues = false; foreach (var id in ids.Where(p => p > 0)) { customdelete_hasissues = false; T_PositionLevel t_positionlevel = db.T_PositionLevels.Find(id); if (CheckBeforeDelete(t_positionlevel)) { if (!CustomDelete(t_positionlevel, out customdelete_hasissues, "DeleteBulk")) { var listT_PositionIdentifier = db.T_Positions.Where(p => p.T_PositionIdentifierID == id); foreach (var lst in listT_PositionIdentifier) { db.T_Positions.Remove(lst); } db.SaveChanges(); db.Entry(t_positionlevel).State = EntityState.Deleted; db.T_PositionLevels.Remove(t_positionlevel); try { db.SaveChanges(); } catch { } } } } return(Json("Success", "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); }
private bool CustomDelete(T_PositionLevel t_positionlevel, out bool customdelete_hasissues, string command = "") { var result = false; customdelete_hasissues = false; return(result); }
private bool CustomSaveOnImport(T_PositionLevel t_positionlevel, out string customerror, int i) { var result = false; customerror = ""; return(result); }
public ActionResult Details(int?id, string HostingEntityName, string AssociatedType, string defaultview) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (!CustomAuthorizationBeforeDetails(id, HostingEntityName, AssociatedType)) { return(RedirectToAction("Index", "Error")); } T_PositionLevel t_positionlevel = db.T_PositionLevels.Find(id); if (t_positionlevel == null) { return(HttpNotFound()); } if (string.IsNullOrEmpty(defaultview)) { defaultview = "Details"; } GetTemplatesForDetails(defaultview); ViewData["AssociatedType"] = AssociatedType; ViewData["HostingEntityName"] = HostingEntityName; LoadViewDataBeforeOnEdit(t_positionlevel); if (!string.IsNullOrEmpty(AssociatedType)) { LoadViewDataForCount(t_positionlevel, AssociatedType); } ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnDetails", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnDetails", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnDetails"); return(View(ViewBag.TemplatesName, t_positionlevel)); }
public ActionResult CreateWizard([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_PositionLevel t_positionlevel, string UrlReferrer) { CheckBeforeSave(t_positionlevel); if (ModelState.IsValid) { bool customcreate_hasissues = false; if (!CustomSaveOnCreate(t_positionlevel, out customcreate_hasissues, "Create")) { db.T_PositionLevels.Add(t_positionlevel); db.SaveChanges(); } if (!customcreate_hasissues) { RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_positionlevel, "Create", ""); if (customRedirectAction != null) { return(customRedirectAction); } if (!string.IsNullOrEmpty(UrlReferrer)) { return(Redirect(UrlReferrer)); } else { return(RedirectToAction("Index")); } } } LoadViewDataAfterOnCreate(t_positionlevel); ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnCreate", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnCreate", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnCreate"); return(View(t_positionlevel)); }
public string CheckBeforeSave(T_PositionLevel t_positionlevel, string command = "") { var AlertMsg = ""; // Write your logic here //Make sure to assign AlertMsg with proper message //AlertMsg = "Validation Alert - Before Save !! Information not saved."; //ModelState.AddModelError("CustomError", AlertMsg); //ViewBag.ApplicationError = AlertMsg; return(AlertMsg); }
public bool CheckBeforeDelete(T_PositionLevel t_positionlevel) { var result = true; // Write your logic here if (!result) { var AlertMsg = "Validation Alert - Before Delete !! Information not deleted."; ModelState.AddModelError("CustomError", AlertMsg); ViewBag.ApplicationError = AlertMsg; } return(result); }
public ActionResult Create([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_PositionLevel t_positionlevel, string UrlReferrer, bool?IsDDAdd) { string command = Request.Form["hdncommand"]; CheckBeforeSave(t_positionlevel, command); if (ModelState.IsValid) { bool customcreate_hasissues = false; if (!CustomSaveOnCreate(t_positionlevel, out customcreate_hasissues, command)) { db.T_PositionLevels.Add(t_positionlevel); db.SaveChanges(); } if (!customcreate_hasissues) { RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_positionlevel, "Create", command); if (customRedirectAction != null) { return(customRedirectAction); } if (command == "Create & Continue") { return(RedirectToAction("Edit", new { Id = t_positionlevel.Id, UrlReferrer = UrlReferrer })); } if (!string.IsNullOrEmpty(UrlReferrer)) { return(Redirect(UrlReferrer)); } else { return(RedirectToAction("Index")); } } } if (IsDDAdd != null) { ViewBag.IsDDAdd = Convert.ToBoolean(IsDDAdd); } LoadViewDataAfterOnCreate(t_positionlevel); ViewData["T_PositionLevelParentUrl"] = UrlReferrer; ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnCreate", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnCreate", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnCreate"); return(View(t_positionlevel)); }
public ActionResult EditWizard([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_PositionLevel t_positionlevel, string UrlReferrer) { CheckBeforeSave(t_positionlevel); if (ModelState.IsValid) { bool customsave_hasissues = false; if (!CustomSaveOnEdit(t_positionlevel, out customsave_hasissues, "Save")) { db.Entry(t_positionlevel).State = EntityState.Modified; db.SaveChanges(); } if (!customsave_hasissues) { RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_positionlevel, "Edit", ""); if (customRedirectAction != null) { return(customRedirectAction); } if (!string.IsNullOrEmpty(UrlReferrer)) { var uri = new Uri(UrlReferrer); var query = HttpUtility.ParseQueryString(uri.Query); if (Convert.ToBoolean(query.Get("IsFilter")) == true) { return(RedirectToAction("Index")); } else { return(Redirect(UrlReferrer)); } } else { return(RedirectToAction("Index")); } } } LoadViewDataAfterOnEdit(t_positionlevel); ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnEdit"); return(View(t_positionlevel)); }
public ActionResult BulkUpdate([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_PositionLevel t_positionlevel, FormCollection collection, string UrlReferrer) { var bulkIds = collection["BulkUpdate"].Split(',').ToList(); var chkUpdate = collection["chkUpdate"]; if (!string.IsNullOrEmpty(chkUpdate)) { bool customsave_hasissues = false; foreach (var id in bulkIds.Where(p => p != string.Empty)) { long objId = long.Parse(id); T_PositionLevel target = db.T_PositionLevels.Find(objId); target.setDateTimeToClientTime(); EntityCopy.CopyValuesForSameObjectType(t_positionlevel, target, chkUpdate); customsave_hasissues = false; CheckBeforeSave(target, "BulkUpdate"); if (ValidateModel(target) && !CustomSaveOnEdit(target, out customsave_hasissues, "BulkUpdate")) { db.Entry(target).State = EntityState.Modified; try { db.SaveChanges(); } catch { } } } } RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_positionlevel, "BulkUpdate", ""); if (customRedirectAction != null) { return(customRedirectAction); } if (!string.IsNullOrEmpty(UrlReferrer)) { return(Redirect(UrlReferrer)); } else { return(RedirectToAction("Index")); } }
public ActionResult DeleteConfirmed(T_PositionLevel t_positionlevel, string UrlReferrer) { if (!User.CanDelete("T_PositionLevel")) { return(RedirectToAction("Index", "Error")); } if (CheckBeforeDelete(t_positionlevel)) { bool customdelete_hasissues = false; if (!CustomDelete(t_positionlevel, out customdelete_hasissues, "Delete")) { var listT_PositionIdentifier = db.T_Positions.Where(p => p.T_PositionIdentifierID == t_positionlevel.Id); foreach (var lst in listT_PositionIdentifier) { db.T_Positions.Remove(lst); } db.SaveChanges(); db.Entry(t_positionlevel).State = EntityState.Deleted; db.T_PositionLevels.Remove(t_positionlevel); db.SaveChanges(); } if (!customdelete_hasissues) { if (!string.IsNullOrEmpty(UrlReferrer)) { return(Redirect(UrlReferrer)); } if (ViewData["T_PositionLevelParentUrl"] != null) { string parentUrl = ViewData["T_PositionLevelParentUrl"].ToString(); ViewData["T_PositionLevelParentUrl"] = null; return(Redirect(parentUrl)); } else { return(RedirectToAction("Index")); } } } return(View(t_positionlevel)); }
public ActionResult EditQuick([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_PositionLevel t_positionlevel, string UrlReferrer, bool?IsAddPop, string AssociatedEntity) { string command = Request.Form["hdncommand"]; CheckBeforeSave(t_positionlevel, command); if (ModelState.IsValid) { bool customsave_hasissues = false; if (!CustomSaveOnEdit(t_positionlevel, out customsave_hasissues, command)) { db.Entry(t_positionlevel).State = EntityState.Modified; db.SaveChanges(); } var result = new { Result = "Succeed", UrlRefr = UrlReferrer }; if (!customsave_hasissues) { return(Json(result, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); } } else { var errors = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { errors += error.ErrorMessage + ". "; } } var result = new { Result = "fail", UrlRefr = errors }; return(Json(result, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); } LoadViewDataAfterOnEdit(t_positionlevel); ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnEdit"); return(View(t_positionlevel)); }
public ActionResult EditQuick(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string viewtype) { if (!User.CanEdit("T_PositionLevel") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType)) { return(RedirectToAction("Index", "Error")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (string.IsNullOrEmpty(viewtype)) { viewtype = "EditQuick"; } GetTemplatesForEditQuick(viewtype); T_PositionLevel t_positionlevel = db.T_PositionLevels.Find(id); if (t_positionlevel == null) { return(HttpNotFound()); } if (UrlReferrer != null) { ViewData["T_PositionLevelParentUrl"] = UrlReferrer; } if (ViewData["T_PositionLevelParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_PositionLevel") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_PositionLevel/Edit/" + t_positionlevel.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_PositionLevel/Create")) { ViewData["T_PositionLevelParentUrl"] = Request.UrlReferrer; } ViewData["HostingEntityName"] = HostingEntityName; ViewData["AssociatedType"] = AssociatedType; LoadViewDataBeforeOnEdit(t_positionlevel); ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnEdit"); var objT_PositionLevel = new List <T_PositionLevel>(); ViewBag.T_PositionLevelDD = new SelectList(objT_PositionLevel, "ID", "DisplayValue"); return(View(t_positionlevel)); }
// GET: /T_PositionLevel/Delete/5 public ActionResult Delete(int id) { if (!User.CanDelete("T_PositionLevel") || !CustomAuthorizationBeforeDelete(id)) { return(RedirectToAction("Index", "Error")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } T_PositionLevel t_positionlevel = db.T_PositionLevels.Find(id); if (t_positionlevel == null) { throw(new Exception("Deleted")); } if (ViewData["T_PositionLevelParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_PositionLevel")) { ViewData["T_PositionLevelParentUrl"] = Request.UrlReferrer; } return(View(t_positionlevel)); }
public ActionResult CreateQuick([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_PositionLevel t_positionlevel, string UrlReferrer, bool?IsAddPop, string AssociatedEntity, string HostingEntityName, string HostingEntityID) { CheckBeforeSave(t_positionlevel); if (ModelState.IsValid) { bool customcreate_hasissues = false; if (!CustomSaveOnCreate(t_positionlevel, out customcreate_hasissues, "Create")) { db.T_PositionLevels.Add(t_positionlevel); db.SaveChanges(); } if (!customcreate_hasissues) { return(Json("FROMPOPUP", "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); } } else { var errors = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { errors += error.ErrorMessage + ". "; } } return(Json(errors, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); } LoadViewDataAfterOnCreate(t_positionlevel); ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnCreate", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnCreate", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnCreate"); if (!string.IsNullOrEmpty(AssociatedEntity)) { LoadViewDataForCount(t_positionlevel, AssociatedEntity); } return(View(t_positionlevel)); }
private void CustomLoadViewDataListAfterEdit(T_PositionLevel t_positionlevel) { }
private RedirectToRouteResult CustomRedirectUrl(T_PositionLevel t_positionlevel, string action, string command = "") { // Sample Custom implemention below // return RedirectToAction("Index", "T_PositionLevel"); return(null); }
public void OnDeleting(T_PositionLevel t_positionlevel) { // Write your logic here }
public ActionResult Edit([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_PositionLevel t_positionlevel, string UrlReferrer) { string command = Request.Form["hdncommand"]; CheckBeforeSave(t_positionlevel, command); if (ModelState.IsValid) { bool customsave_hasissues = false; if (!CustomSaveOnEdit(t_positionlevel, out customsave_hasissues, command)) { db.Entry(t_positionlevel).State = EntityState.Modified; db.SaveChanges(); } if (!customsave_hasissues) { RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_positionlevel, "Edit", command); if (customRedirectAction != null) { return(customRedirectAction); } if (command != "Save") { if (command == "SaveNextPrev") { long NextPreId = Convert.ToInt64(Request.Form["hdnNextPrevId"]); return(RedirectToAction("Edit", new { Id = NextPreId, UrlReferrer = UrlReferrer })); } else { return(RedirectToAction("Edit", new { Id = t_positionlevel.Id, UrlReferrer = UrlReferrer })); } } if (!string.IsNullOrEmpty(UrlReferrer)) { var uri = new Uri(UrlReferrer); var query = HttpUtility.ParseQueryString(uri.Query); if (Convert.ToBoolean(query.Get("IsFilter")) == true) { return(RedirectToAction("Index")); } else { return(Redirect(UrlReferrer)); } } else { return(RedirectToAction("Index")); } } } // NEXT-PREVIOUS DROP DOWN CODE TempData.Keep(); string json = ""; if (TempData["T_PositionLevellist"] == null) { json = Newtonsoft.Json.JsonConvert.SerializeObject(db.T_PositionLevels.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }).ToList()); } else { ViewBag.EntityT_PositionLevelDisplayValueEdit = TempData["T_PositionLevellist"]; json = Newtonsoft.Json.JsonConvert.SerializeObject(TempData["T_PositionLevellist"]); } Newtonsoft.Json.JsonSerializerSettings serSettings = new Newtonsoft.Json.JsonSerializerSettings(); serSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(); var lst = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <object> >(json, serSettings); ViewBag.EntityT_PositionLevelDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue"); // LoadViewDataAfterOnEdit(t_positionlevel); ViewData["T_PositionLevelParentUrl"] = UrlReferrer; ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnEdit"); return(View(t_positionlevel)); }
public ActionResult Edit(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string defaultview) { if (!User.CanEdit("T_PositionLevel") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType)) { return(RedirectToAction("Index", "Error")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } T_PositionLevel t_positionlevel = db.T_PositionLevels.Find(id); // NEXT-PREVIOUS DROP DOWN CODE TempData.Keep(); string json = ""; if (TempData["T_PositionLevellist"] == null) { json = Newtonsoft.Json.JsonConvert.SerializeObject(db.T_PositionLevels.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }).ToList()); } else { ViewBag.EntityT_PositionLevelDisplayValueEdit = TempData["T_PositionLevellist"]; json = Newtonsoft.Json.JsonConvert.SerializeObject(TempData["T_PositionLevellist"]); } Newtonsoft.Json.JsonSerializerSettings serSettings = new Newtonsoft.Json.JsonSerializerSettings(); serSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(); var lst = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <object> >(json, serSettings); ViewBag.EntityT_PositionLevelDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue"); // if (t_positionlevel == null) { return(HttpNotFound()); } if (string.IsNullOrEmpty(defaultview)) { defaultview = "Edit"; } GetTemplatesForEdit(defaultview); // NEXT-PREVIOUS DROP DOWN CODE SelectList selitm = new SelectList(lst, "ID", "DisplayValue"); List <SelectListItem> newList = selitm.ToList(); if (Request.UrlReferrer != null && Request.UrlReferrer.AbsolutePath.EndsWith("/T_PositionLevel/Create")) { newList.Insert(0, (new SelectListItem { Text = t_positionlevel.DisplayValue, Value = t_positionlevel.Id.ToString() })); ViewBag.EntityT_PositionLevelDisplayValueEdit = newList; TempData["T_PositionLevellist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text }); } else if (!newList.Exists(p => p.Value == Convert.ToString(t_positionlevel.Id))) { if (newList.Count > 0) { newList[0].Text = t_positionlevel.DisplayValue; newList[0].Value = t_positionlevel.Id.ToString(); } else { newList.Insert(0, (new SelectListItem { Text = t_positionlevel.DisplayValue, Value = t_positionlevel.Id.ToString() })); } ViewBag.EntityT_PositionLevelDisplayValueEdit = newList; TempData["T_PositionLevellist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text }); } // if (UrlReferrer != null) { ViewData["T_PositionLevelParentUrl"] = UrlReferrer; } if (ViewData["T_PositionLevelParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_PositionLevel") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_PositionLevel/Edit/" + t_positionlevel.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_PositionLevel/Create")) { ViewData["T_PositionLevelParentUrl"] = Request.UrlReferrer; } ViewData["HostingEntityName"] = HostingEntityName; ViewData["AssociatedType"] = AssociatedType; LoadViewDataBeforeOnEdit(t_positionlevel); ViewBag.T_PositionLevelIsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", false); ViewBag.T_PositionLevelIsGroupsHiddenRule = checkHidden("T_PositionLevel", "OnEdit", true); ViewBag.T_PositionLevelIsSetValueUIRule = checkSetValueUIRule("T_PositionLevel", "OnEdit"); return(View(t_positionlevel)); }
public void OnSaving(T_PositionLevel t_positionlevel, ApplicationContext db) { // Write your logic here }
public void AfterSave(T_PositionLevel t_positionlevel) { // Write your logic here }