public ActionResult DeleteBulk(long[] ids, string UrlReferrer)
        {
            if (User != null && (!((CustomPrincipal)User).CanUseVerb("BulkDelete", "T_AllFacilities", User) || !User.CanDelete("T_AllFacilities")))
            {
                return(RedirectToAction("Index", "Error"));
            }
            bool customdelete_hasissues = false;

            foreach (var id in ids.Where(p => p > 0))
            {
                customdelete_hasissues = false;
                T_AllFacilities t_allfacilities = db.T_AllFacilitiess.Find(id);
                if (CheckBeforeDelete(t_allfacilities))
                {
                    if (!CustomDelete(t_allfacilities, out customdelete_hasissues, "DeleteBulk"))
                    {
                        var listT_EmploymentRecordHiredAtFacility = db.T_ServiceRecords.Where(p => p.T_EmploymentRecordHiredAtFacilityID == id);
                        foreach (var lst in listT_EmploymentRecordHiredAtFacility)
                        {
                            db.T_ServiceRecords.Remove(lst);
                        }
                        db.SaveChanges();
                        db.Entry(t_allfacilities).State = EntityState.Deleted;
                        db.T_AllFacilitiess.Remove(t_allfacilities);
                        try
                        {
                            db.SaveChanges();
                        }
                        catch { }
                    }
                }
            }
            return(Json("Success", "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet));
        }
        // GET: /T_AllFacilities/Details/5
        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_AllFacilities t_allfacilities = db.T_AllFacilitiess.Find(id);

            if (t_allfacilities == null)
            {
                return(HttpNotFound());
            }
            if (string.IsNullOrEmpty(defaultview))
            {
                defaultview = "Details";
            }
            GetTemplatesForDetails(defaultview);
            ViewData["AssociatedType"]    = AssociatedType;
            ViewData["HostingEntityName"] = HostingEntityName;
            LoadViewDataBeforeOnEdit(t_allfacilities);
            if (!string.IsNullOrEmpty(AssociatedType))
            {
                LoadViewDataForCount(t_allfacilities, AssociatedType);
            }
            ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnDetails", false);
            ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnDetails", true);
            ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnDetails");
            return(View(ViewBag.TemplatesName, t_allfacilities));
        }
        private bool CustomDelete(T_AllFacilities t_allfacilities, out bool customdelete_hasissues, string command = "")
        {
            var result = false;

            customdelete_hasissues = false;
            return(result);
        }
        private bool CustomSaveOnEdit(T_AllFacilities t_allfacilities, out bool customsave_hasissues, string command = "")
        {
            var result = false;

            customsave_hasissues = false;
            return(result);
        }
        public ActionResult CreateWizard([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_AllFacilities t_allfacilities, string UrlReferrer)
        {
            CheckBeforeSave(t_allfacilities);
            if (ModelState.IsValid)
            {
                bool customcreate_hasissues = false;
                if (!CustomSaveOnCreate(t_allfacilities, out customcreate_hasissues, "Create"))
                {
                    db.T_AllFacilitiess.Add(t_allfacilities);
                    db.SaveChanges();
                }
                if (!customcreate_hasissues)
                {
                    RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_allfacilities, "Create", "");
                    if (customRedirectAction != null)
                    {
                        return(customRedirectAction);
                    }
                    if (!string.IsNullOrEmpty(UrlReferrer))
                    {
                        return(Redirect(UrlReferrer));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }

            LoadViewDataAfterOnCreate(t_allfacilities);
            ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnCreate", false);
            ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnCreate", true);
            ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnCreate");
            return(View(t_allfacilities));
        }
        private bool CustomSaveOnImport(T_AllFacilities t_allfacilities, out string customerror, int i)
        {
            var result = false;

            customerror = "";
            return(result);
        }
        public string CheckBeforeSave(T_AllFacilities t_allfacilities, 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_AllFacilities t_allfacilities)
        {
            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_AllFacilities t_allfacilities, string UrlReferrer, bool?IsDDAdd)
        {
            string command = Request.Form["hdncommand"];

            CheckBeforeSave(t_allfacilities, command);

            if (ModelState.IsValid)
            {
                bool customcreate_hasissues = false;
                if (!CustomSaveOnCreate(t_allfacilities, out customcreate_hasissues, command))
                {
                    db.T_AllFacilitiess.Add(t_allfacilities);
                    db.SaveChanges();
                }
                if (!customcreate_hasissues)
                {
                    RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_allfacilities, "Create", command);
                    if (customRedirectAction != null)
                    {
                        return(customRedirectAction);
                    }
                    if (command == "Create & Continue")
                    {
                        return(RedirectToAction("Edit", new { Id = t_allfacilities.Id, UrlReferrer = UrlReferrer }));
                    }
                    if (!string.IsNullOrEmpty(UrlReferrer))
                    {
                        return(Redirect(UrlReferrer));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }

            if (IsDDAdd != null)
            {
                ViewBag.IsDDAdd = Convert.ToBoolean(IsDDAdd);
            }
            LoadViewDataAfterOnCreate(t_allfacilities);
            ViewData["T_AllFacilitiesParentUrl"]      = UrlReferrer;
            ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnCreate", false);
            ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnCreate", true);
            ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnCreate");
            return(View(t_allfacilities));
        }
 public ActionResult EditWizard([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_AllFacilities t_allfacilities, string UrlReferrer)
 {
     CheckBeforeSave(t_allfacilities);
     if (ModelState.IsValid)
     {
         bool customsave_hasissues = false;
         if (!CustomSaveOnEdit(t_allfacilities, out customsave_hasissues, "Save"))
         {
             db.Entry(t_allfacilities).State = EntityState.Modified;
             db.SaveChanges();
         }
         if (!customsave_hasissues)
         {
             RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_allfacilities, "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_allfacilities);
     ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnEdit", false);
     ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnEdit", true);
     ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnEdit");
     return(View(t_allfacilities));
 }
        public ActionResult BulkUpdate([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_AllFacilities t_allfacilities, 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_AllFacilities target = db.T_AllFacilitiess.Find(objId);
                    target.setDateTimeToClientTime();
                    EntityCopy.CopyValuesForSameObjectType(t_allfacilities, 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_allfacilities, "BulkUpdate", "");

            if (customRedirectAction != null)
            {
                return(customRedirectAction);
            }
            if (!string.IsNullOrEmpty(UrlReferrer))
            {
                return(Redirect(UrlReferrer));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
 public ActionResult DeleteConfirmed(T_AllFacilities t_allfacilities, string UrlReferrer)
 {
     if (!User.CanDelete("T_AllFacilities"))
     {
         return(RedirectToAction("Index", "Error"));
     }
     if (CheckBeforeDelete(t_allfacilities))
     {
         bool customdelete_hasissues = false;
         if (!CustomDelete(t_allfacilities, out customdelete_hasissues, "Delete"))
         {
             var listT_EmploymentRecordHiredAtFacility = db.T_ServiceRecords.Where(p => p.T_EmploymentRecordHiredAtFacilityID == t_allfacilities.Id);
             foreach (var lst in listT_EmploymentRecordHiredAtFacility)
             {
                 db.T_ServiceRecords.Remove(lst);
             }
             db.SaveChanges();
             db.Entry(t_allfacilities).State = EntityState.Deleted;
             db.T_AllFacilitiess.Remove(t_allfacilities);
             db.SaveChanges();
         }
         if (!customdelete_hasissues)
         {
             if (!string.IsNullOrEmpty(UrlReferrer))
             {
                 return(Redirect(UrlReferrer));
             }
             if (ViewData["T_AllFacilitiesParentUrl"] != null)
             {
                 string parentUrl = ViewData["T_AllFacilitiesParentUrl"].ToString();
                 ViewData["T_AllFacilitiesParentUrl"] = null;
                 return(Redirect(parentUrl));
             }
             else
             {
                 return(RedirectToAction("Index"));
             }
         }
     }
     return(View(t_allfacilities));
 }
        public ActionResult EditQuick([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_AllFacilities t_allfacilities, string UrlReferrer, bool?IsAddPop, string AssociatedEntity)
        {
            string command = Request.Form["hdncommand"];

            CheckBeforeSave(t_allfacilities, command);

            if (ModelState.IsValid)
            {
                bool customsave_hasissues = false;
                if (!CustomSaveOnEdit(t_allfacilities, out customsave_hasissues, command))
                {
                    db.Entry(t_allfacilities).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_allfacilities);
            ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnEdit", false);
            ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnEdit", true);
            ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnEdit");
            return(View(t_allfacilities));
        }
        // GET: /T_AllFacilities/Edit/5
        public ActionResult EditQuick(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string viewtype)
        {
            if (!User.CanEdit("T_AllFacilities") || !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_AllFacilities t_allfacilities = db.T_AllFacilitiess.Find(id);

            if (t_allfacilities == null)
            {
                return(HttpNotFound());
            }
            if (UrlReferrer != null)
            {
                ViewData["T_AllFacilitiesParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_AllFacilitiesParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilities") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilities/Edit/" + t_allfacilities.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilities/Create"))
            {
                ViewData["T_AllFacilitiesParentUrl"] = Request.UrlReferrer;
            }
            ViewData["HostingEntityName"] = HostingEntityName;
            ViewData["AssociatedType"]    = AssociatedType;
            LoadViewDataBeforeOnEdit(t_allfacilities);
            ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnEdit", false);
            ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnEdit", true);
            ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnEdit");
            var objT_AllFacilities = new List <T_AllFacilities>();

            ViewBag.T_AllFacilitiesDD = new SelectList(objT_AllFacilities, "ID", "DisplayValue");
            return(View(t_allfacilities));
        }
        // GET: /T_AllFacilities/Delete/5
        public ActionResult Delete(int id)
        {
            if (!User.CanDelete("T_AllFacilities") || !CustomAuthorizationBeforeDelete(id))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_AllFacilities t_allfacilities = db.T_AllFacilitiess.Find(id);

            if (t_allfacilities == null)
            {
                throw(new Exception("Deleted"));
            }
            if (ViewData["T_AllFacilitiesParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilities"))
            {
                ViewData["T_AllFacilitiesParentUrl"] = Request.UrlReferrer;
            }
            return(View(t_allfacilities));
        }
 public ActionResult CreateQuick([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_AllFacilities t_allfacilities, string UrlReferrer, bool?IsAddPop, string AssociatedEntity, string HostingEntityName, string HostingEntityID)
 {
     CheckBeforeSave(t_allfacilities);
     if (ModelState.IsValid)
     {
         bool customcreate_hasissues = false;
         if (!CustomSaveOnCreate(t_allfacilities, out customcreate_hasissues, "Create"))
         {
             db.T_AllFacilitiess.Add(t_allfacilities);
             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_allfacilities);
     ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnCreate", false);
     ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnCreate", true);
     ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnCreate");
     if (!string.IsNullOrEmpty(AssociatedEntity))
     {
         LoadViewDataForCount(t_allfacilities, AssociatedEntity);
     }
     return(View(t_allfacilities));
 }
 public void OnSaving(T_AllFacilities t_allfacilities, ApplicationContext db)
 {
     // Write your logic here
 }
 public void AfterSave(T_AllFacilities t_allfacilities)
 {
     // Write your logic here
 }
 public void OnDeleting(T_AllFacilities t_allfacilities)
 {
     // Write your logic here
 }
        // GET: /T_AllFacilities/Edit/5
        public ActionResult Edit(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string defaultview)
        {
            if (!User.CanEdit("T_AllFacilities") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_AllFacilities t_allfacilities = db.T_AllFacilitiess.Find(id);

            // NEXT-PREVIOUS DROP DOWN CODE
            TempData.Keep();
            string json = "";

            if (TempData["T_AllFacilitieslist"] == null)
            {
                json = Newtonsoft.Json.JsonConvert.SerializeObject(db.T_AllFacilitiess.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }).ToList());
            }
            else
            {
                ViewBag.EntityT_AllFacilitiesDisplayValueEdit = TempData["T_AllFacilitieslist"];
                json = Newtonsoft.Json.JsonConvert.SerializeObject(TempData["T_AllFacilitieslist"]);
            }

            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_AllFacilitiesDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            if (t_allfacilities == 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_AllFacilities/Create"))
            {
                newList.Insert(0, (new SelectListItem {
                    Text = t_allfacilities.DisplayValue, Value = t_allfacilities.Id.ToString()
                }));
                ViewBag.EntityT_AllFacilitiesDisplayValueEdit = newList;
                TempData["T_AllFacilitieslist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            else if (!newList.Exists(p => p.Value == Convert.ToString(t_allfacilities.Id)))
            {
                if (newList.Count > 0)
                {
                    newList[0].Text  = t_allfacilities.DisplayValue;
                    newList[0].Value = t_allfacilities.Id.ToString();
                }
                else
                {
                    newList.Insert(0, (new SelectListItem {
                        Text = t_allfacilities.DisplayValue, Value = t_allfacilities.Id.ToString()
                    }));
                }
                ViewBag.EntityT_AllFacilitiesDisplayValueEdit = newList;
                TempData["T_AllFacilitieslist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            //
            if (UrlReferrer != null)
            {
                ViewData["T_AllFacilitiesParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_AllFacilitiesParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilities") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilities/Edit/" + t_allfacilities.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilities/Create"))
            {
                ViewData["T_AllFacilitiesParentUrl"] = Request.UrlReferrer;
            }
            ViewData["HostingEntityName"] = HostingEntityName;
            ViewData["AssociatedType"]    = AssociatedType;
            LoadViewDataBeforeOnEdit(t_allfacilities);
            ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnEdit", false);
            ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnEdit", true);
            ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnEdit");
            return(View(t_allfacilities));
        }
        public ActionResult Edit([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_AllFacilities t_allfacilities, string UrlReferrer)
        {
            string command = Request.Form["hdncommand"];

            CheckBeforeSave(t_allfacilities, command);
            if (ModelState.IsValid)
            {
                bool customsave_hasissues = false;
                if (!CustomSaveOnEdit(t_allfacilities, out customsave_hasissues, command))
                {
                    db.Entry(t_allfacilities).State = EntityState.Modified;
                    db.SaveChanges();
                }
                if (!customsave_hasissues)
                {
                    RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_allfacilities, "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_allfacilities.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_AllFacilitieslist"] == null)
            {
                json = Newtonsoft.Json.JsonConvert.SerializeObject(db.T_AllFacilitiess.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }).ToList());
            }
            else
            {
                ViewBag.EntityT_AllFacilitiesDisplayValueEdit = TempData["T_AllFacilitieslist"];
                json = Newtonsoft.Json.JsonConvert.SerializeObject(TempData["T_AllFacilitieslist"]);
            }

            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_AllFacilitiesDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            LoadViewDataAfterOnEdit(t_allfacilities);
            ViewData["T_AllFacilitiesParentUrl"]      = UrlReferrer;
            ViewBag.T_AllFacilitiesIsHiddenRule       = checkHidden("T_AllFacilities", "OnEdit", false);
            ViewBag.T_AllFacilitiesIsGroupsHiddenRule = checkHidden("T_AllFacilities", "OnEdit", true);
            ViewBag.T_AllFacilitiesIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilities", "OnEdit");
            return(View(t_allfacilities));
        }
 private RedirectToRouteResult CustomRedirectUrl(T_AllFacilities t_allfacilities, string action, string command = "")
 {
     // Sample Custom implemention below
     // return RedirectToAction("Index", "T_AllFacilities");
     return(null);
 }
 private void CustomLoadViewDataListAfterEdit(T_AllFacilities t_allfacilities)
 {
 }