Exemplo n.º 1
0
        // GET: /T_AllFacilitiesUnit/Delete/5
        public ActionResult Delete(int id)
        {
            if (!User.CanDelete("T_AllFacilitiesUnit") || !CustomAuthorizationBeforeDelete(id))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_AllFacilitiesUnit t_allfacilitiesunit = db.T_AllFacilitiesUnits.Find(id);

            if (t_allfacilitiesunit == null)
            {
                throw(new Exception("Deleted"));
            }
            if (ViewData["T_AllFacilitiesUnitParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilitiesUnit"))
            {
                ViewData["T_AllFacilitiesUnitParentUrl"] = Request.UrlReferrer;
            }
            return(View(t_allfacilitiesunit));
        }
Exemplo n.º 2
0
 public ActionResult CreateQuick([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description,T_UnitsforAllFaciltiesID")] T_AllFacilitiesUnit t_allfacilitiesunit, string UrlReferrer, bool?IsAddPop, string AssociatedEntity, string HostingEntityName, string HostingEntityID)
 {
     CheckBeforeSave(t_allfacilitiesunit);
     if (ModelState.IsValid)
     {
         bool customcreate_hasissues = false;
         if (!CustomSaveOnCreate(t_allfacilitiesunit, out customcreate_hasissues, "Create"))
         {
             db.T_AllFacilitiesUnits.Add(t_allfacilitiesunit);
             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_allfacilitiesunit);
     ViewBag.T_AllFacilitiesUnitIsHiddenRule       = checkHidden("T_AllFacilitiesUnit", "OnCreate", false);
     ViewBag.T_AllFacilitiesUnitIsGroupsHiddenRule = checkHidden("T_AllFacilitiesUnit", "OnCreate", true);
     ViewBag.T_AllFacilitiesUnitIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilitiesUnit", "OnCreate");
     if (!string.IsNullOrEmpty(AssociatedEntity))
     {
         LoadViewDataForCount(t_allfacilitiesunit, AssociatedEntity);
     }
     return(View(t_allfacilitiesunit));
 }
Exemplo n.º 3
0
        // GET: /T_AllFacilitiesUnit/EditWizard/5
        public ActionResult EditWizard(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string viewtype)
        {
            if (!User.CanEdit("T_AllFacilitiesUnit") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (string.IsNullOrEmpty(viewtype))
            {
                viewtype = "EditWizard";
            }
            GetTemplatesForEditWizard(viewtype);
            T_AllFacilitiesUnit t_allfacilitiesunit = db.T_AllFacilitiesUnits.Find(id);

            if (t_allfacilitiesunit == null)
            {
                return(HttpNotFound());
            }

            if (UrlReferrer != null)
            {
                ViewData["T_AllFacilitiesUnitParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_AllFacilitiesUnitParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilitiesUnit"))
            {
                ViewData["T_AllFacilitiesUnitParentUrl"] = Request.UrlReferrer;
            }
            LoadViewDataBeforeOnEdit(t_allfacilitiesunit);
            ViewBag.T_AllFacilitiesUnitIsHiddenRule       = checkHidden("T_AllFacilitiesUnit", "OnEdit", false);
            ViewBag.T_AllFacilitiesUnitIsGroupsHiddenRule = checkHidden("T_AllFacilitiesUnit", "OnEdit", true);
            ViewBag.T_AllFacilitiesUnitIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilitiesUnit", "OnEdit");
            return(View(t_allfacilitiesunit));
        }
Exemplo n.º 4
0
        public ActionResult Edit([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description,T_UnitsforAllFaciltiesID")] T_AllFacilitiesUnit t_allfacilitiesunit, string UrlReferrer)
        {
            string command = Request.Form["hdncommand"];

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

            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_AllFacilitiesUnitDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            LoadViewDataAfterOnEdit(t_allfacilitiesunit);
            ViewData["T_AllFacilitiesUnitParentUrl"]      = UrlReferrer;
            ViewBag.T_AllFacilitiesUnitIsHiddenRule       = checkHidden("T_AllFacilitiesUnit", "OnEdit", false);
            ViewBag.T_AllFacilitiesUnitIsGroupsHiddenRule = checkHidden("T_AllFacilitiesUnit", "OnEdit", true);
            ViewBag.T_AllFacilitiesUnitIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilitiesUnit", "OnEdit");
            return(View(t_allfacilitiesunit));
        }
Exemplo n.º 5
0
        // GET: /T_AllFacilitiesUnit/Edit/5
        public ActionResult Edit(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string defaultview)
        {
            if (!User.CanEdit("T_AllFacilitiesUnit") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_AllFacilitiesUnit t_allfacilitiesunit = db.T_AllFacilitiesUnits.Find(id);

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

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

            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_AllFacilitiesUnitDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            if (t_allfacilitiesunit == 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_AllFacilitiesUnit/Create"))
            {
                newList.Insert(0, (new SelectListItem {
                    Text = t_allfacilitiesunit.DisplayValue, Value = t_allfacilitiesunit.Id.ToString()
                }));
                ViewBag.EntityT_AllFacilitiesUnitDisplayValueEdit = newList;
                TempData["T_AllFacilitiesUnitlist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            else if (!newList.Exists(p => p.Value == Convert.ToString(t_allfacilitiesunit.Id)))
            {
                if (newList.Count > 0)
                {
                    newList[0].Text  = t_allfacilitiesunit.DisplayValue;
                    newList[0].Value = t_allfacilitiesunit.Id.ToString();
                }
                else
                {
                    newList.Insert(0, (new SelectListItem {
                        Text = t_allfacilitiesunit.DisplayValue, Value = t_allfacilitiesunit.Id.ToString()
                    }));
                }
                ViewBag.EntityT_AllFacilitiesUnitDisplayValueEdit = newList;
                TempData["T_AllFacilitiesUnitlist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            //
            if (UrlReferrer != null)
            {
                ViewData["T_AllFacilitiesUnitParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_AllFacilitiesUnitParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilitiesUnit") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilitiesUnit/Edit/" + t_allfacilitiesunit.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_AllFacilitiesUnit/Create"))
            {
                ViewData["T_AllFacilitiesUnitParentUrl"] = Request.UrlReferrer;
            }
            ViewData["HostingEntityName"] = HostingEntityName;
            ViewData["AssociatedType"]    = AssociatedType;
            LoadViewDataBeforeOnEdit(t_allfacilitiesunit);
            ViewBag.T_AllFacilitiesUnitIsHiddenRule       = checkHidden("T_AllFacilitiesUnit", "OnEdit", false);
            ViewBag.T_AllFacilitiesUnitIsGroupsHiddenRule = checkHidden("T_AllFacilitiesUnit", "OnEdit", true);
            ViewBag.T_AllFacilitiesUnitIsSetValueUIRule   = checkSetValueUIRule("T_AllFacilitiesUnit", "OnEdit");
            return(View(t_allfacilitiesunit));
        }
Exemplo n.º 6
0
 public void AfterSave(T_AllFacilitiesUnit t_allfacilitiesunit)
 {
     // Write your logic here
 }
Exemplo n.º 7
0
 public void OnSaving(T_AllFacilitiesUnit t_allfacilitiesunit, ApplicationContext db)
 {
     // Write your logic here
 }
Exemplo n.º 8
0
 public void OnDeleting(T_AllFacilitiesUnit t_allfacilitiesunit)
 {
     // Write your logic here
 }
Exemplo n.º 9
0
 private RedirectToRouteResult CustomRedirectUrl(T_AllFacilitiesUnit t_allfacilitiesunit, string action, string command = "")
 {
     // Sample Custom implemention below
     // return RedirectToAction("Index", "T_AllFacilitiesUnit");
     return(null);
 }
Exemplo n.º 10
0
 private void CustomLoadViewDataListAfterEdit(T_AllFacilitiesUnit t_allfacilitiesunit)
 {
 }