Esempio n. 1
0
        public ActionResult EditQuick([Bind(Include = "Id,ConcurrencyKey,T_CredentialName,T_Description,T_IssueAuthority")] T_Credential t_credential, string UrlReferrer, bool?IsAddPop, string AssociatedEntity)
        {
            string command = Request.Form["hdncommand"];

            CheckBeforeSave(t_credential, command);

            if (ModelState.IsValid)
            {
                bool customsave_hasissues = false;
                if (!CustomSaveOnEdit(t_credential, out customsave_hasissues, command))
                {
                    db.Entry(t_credential).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_credential);
            ViewBag.T_CredentialIsHiddenRule       = checkHidden("T_Credential", "OnEdit", false);
            ViewBag.T_CredentialIsGroupsHiddenRule = checkHidden("T_Credential", "OnEdit", true);
            ViewBag.T_CredentialIsSetValueUIRule   = checkSetValueUIRule("T_Credential", "OnEdit");
            return(View(t_credential));
        }
Esempio n. 2
0
        public ActionResult EditQuick(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string viewtype)
        {
            if (!User.CanEdit("T_Credential") || !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_Credential t_credential = db.T_Credentials.Find(id);

            if (t_credential == null)
            {
                return(HttpNotFound());
            }
            if (UrlReferrer != null)
            {
                ViewData["T_CredentialParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_CredentialParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Credential") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Credential/Edit/" + t_credential.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Credential/Create"))
            {
                ViewData["T_CredentialParentUrl"] = Request.UrlReferrer;
            }
            ViewData["HostingEntityName"] = HostingEntityName;
            ViewData["AssociatedType"]    = AssociatedType;
            LoadViewDataBeforeOnEdit(t_credential);
            ViewBag.T_CredentialIsHiddenRule       = checkHidden("T_Credential", "OnEdit", false);
            ViewBag.T_CredentialIsGroupsHiddenRule = checkHidden("T_Credential", "OnEdit", true);
            ViewBag.T_CredentialIsSetValueUIRule   = checkSetValueUIRule("T_Credential", "OnEdit");
            var objT_Credential = new List <T_Credential>();

            ViewBag.T_CredentialDD = new SelectList(objT_Credential, "ID", "DisplayValue");
            return(View(t_credential));
        }
Esempio n. 3
0
        // GET: /T_Credential/Delete/5
        public ActionResult Delete(int id)
        {
            if (!User.CanDelete("T_Credential") || !CustomAuthorizationBeforeDelete(id))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_Credential t_credential = db.T_Credentials.Find(id);

            if (t_credential == null)
            {
                throw(new Exception("Deleted"));
            }
            if (ViewData["T_CredentialParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Credential"))
            {
                ViewData["T_CredentialParentUrl"] = Request.UrlReferrer;
            }
            return(View(t_credential));
        }
Esempio n. 4
0
 public ActionResult CreateQuick([Bind(Include = "Id,ConcurrencyKey,T_CredentialName,T_Description,T_IssueAuthority")] T_Credential t_credential, string UrlReferrer, bool?IsAddPop, string AssociatedEntity, string HostingEntityName, string HostingEntityID)
 {
     CheckBeforeSave(t_credential);
     if (ModelState.IsValid)
     {
         bool customcreate_hasissues = false;
         if (!CustomSaveOnCreate(t_credential, out customcreate_hasissues, "Create"))
         {
             db.T_Credentials.Add(t_credential);
             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_credential);
     ViewBag.T_CredentialIsHiddenRule       = checkHidden("T_Credential", "OnCreate", false);
     ViewBag.T_CredentialIsGroupsHiddenRule = checkHidden("T_Credential", "OnCreate", true);
     ViewBag.T_CredentialIsSetValueUIRule   = checkSetValueUIRule("T_Credential", "OnCreate");
     if (!string.IsNullOrEmpty(AssociatedEntity))
     {
         LoadViewDataForCount(t_credential, AssociatedEntity);
     }
     return(View(t_credential));
 }
Esempio n. 5
0
private void CustomLoadViewDataListAfterEdit(T_Credential t_credential)
{
}
Esempio n. 6
0
private void CustomLoadViewDataListBeforeEdit(T_Credential t_credential)
{
}
Esempio n. 7
0
private void CustomLoadViewDataListAfterOnCreate(T_Credential t_credential)
{
}
Esempio n. 8
0
		public void AfterSave(T_Credential t_credential)
        {
            // Write your logic here
 
}
Esempio n. 9
0
        public void OnSaving(T_Credential t_credential, ApplicationContext db)
        {
            // Write your logic here
 
        }
Esempio n. 10
0
		public void OnDeleting(T_Credential t_credential)
        {
            // Write your logic here
 
		}
Esempio n. 11
0
private RedirectToRouteResult CustomRedirectUrl(T_Credential t_credential,string action,string command="")
{
	// Sample Custom implemention below
    // return RedirectToAction("Index", "T_Credential");
    return null;
}
Esempio n. 12
0
private bool CustomDelete(T_Credential t_credential, out bool customdelete_hasissues, string command="")
{
            var result = false;
			customdelete_hasissues = false;
            return result;
}
Esempio n. 13
0
private bool CustomSaveOnImport(T_Credential t_credential, out string customerror, int i)
{
            var result = false;
			customerror = "";
            return result;
}
Esempio n. 14
0
private bool CustomSaveOnEdit(T_Credential t_credential, out bool customsave_hasissues, string command="")
{
            var result = false;
			customsave_hasissues = false;
            return result;
}
Esempio n. 15
0
        public ActionResult Edit([Bind(Include = "Id,ConcurrencyKey,T_CredentialName,T_Description,T_IssueAuthority")] T_Credential t_credential, string UrlReferrer)
        {
            string command = Request.Form["hdncommand"];

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

            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_CredentialDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            LoadViewDataAfterOnEdit(t_credential);
            ViewData["T_CredentialParentUrl"]      = UrlReferrer;
            ViewBag.T_CredentialIsHiddenRule       = checkHidden("T_Credential", "OnEdit", false);
            ViewBag.T_CredentialIsGroupsHiddenRule = checkHidden("T_Credential", "OnEdit", true);
            ViewBag.T_CredentialIsSetValueUIRule   = checkSetValueUIRule("T_Credential", "OnEdit");
            return(View(t_credential));
        }
Esempio n. 16
0
        public ActionResult Edit(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string defaultview)
        {
            if (!User.CanEdit("T_Credential") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_Credential t_credential = db.T_Credentials.Find(id);

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

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

            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_CredentialDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            if (t_credential == 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_Credential/Create"))
            {
                newList.Insert(0, (new SelectListItem {
                    Text = t_credential.DisplayValue, Value = t_credential.Id.ToString()
                }));
                ViewBag.EntityT_CredentialDisplayValueEdit = newList;
                TempData["T_Credentiallist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            else if (!newList.Exists(p => p.Value == Convert.ToString(t_credential.Id)))
            {
                if (newList.Count > 0)
                {
                    newList[0].Text  = t_credential.DisplayValue;
                    newList[0].Value = t_credential.Id.ToString();
                }
                else
                {
                    newList.Insert(0, (new SelectListItem {
                        Text = t_credential.DisplayValue, Value = t_credential.Id.ToString()
                    }));
                }
                ViewBag.EntityT_CredentialDisplayValueEdit = newList;
                TempData["T_Credentiallist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            //
            if (UrlReferrer != null)
            {
                ViewData["T_CredentialParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_CredentialParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Credential") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Credential/Edit/" + t_credential.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Credential/Create"))
            {
                ViewData["T_CredentialParentUrl"] = Request.UrlReferrer;
            }
            ViewData["HostingEntityName"] = HostingEntityName;
            ViewData["AssociatedType"]    = AssociatedType;
            LoadViewDataBeforeOnEdit(t_credential);
            ViewBag.T_CredentialIsHiddenRule       = checkHidden("T_Credential", "OnEdit", false);
            ViewBag.T_CredentialIsGroupsHiddenRule = checkHidden("T_Credential", "OnEdit", true);
            ViewBag.T_CredentialIsSetValueUIRule   = checkSetValueUIRule("T_Credential", "OnEdit");
            return(View(t_credential));
        }