private static void SaveMenu(List <AssemblyMenuModel> menuItems) { using (AppDbContext _db = new AppDbContext()) { foreach (AssemblyMenuModel item in menuItems) { int exists = _db.CM_PERMISSIONS.Where(a => a.CONTROLLER_NAME == item.Controller && a.ACTION_NAME == item.Action).Count(); if (exists < 1) { CM_PERMISSIONS newPermission = new CM_PERMISSIONS(); newPermission.ACTION_NAME = item.Action; newPermission.CONTROLLER_NAME = item.Controller; newPermission.TOGGLE_ICON = "fa fa-angle-left"; newPermission.ISACTIVE = false; newPermission.FORM_URL = "/" + item.Controller + "/" + item.Action; newPermission.PERMISSIONDESCRIPTION = item.Controller + " " + item.Action; newPermission.PARENT_PERMISSION = 3; //newPermission.PERMISSION_ID = 1; _db.CM_PERMISSIONS.Add(newPermission); } } _db.SaveChanges(); } }
public ActionResult Create(PermissionListModel model, bool continueEditing) { if (ModelState.IsValid) { CM_PERMISSIONS cM_PERMISSIONS = new CM_PERMISSIONS { PERMISSION_ID = model.Id, PERMISSIONDESCRIPTION = model.PERMISSIONDESCRIPTION, PARENT_PERMISSION = model.PARENT_PERMISSION, ISACTIVE = model.ISACTIVE, ACTION_NAME = model.ACTION_NAME, CONTROLLER_NAME = model.CONTROLLER_NAME, FORM_URL = model.FORM_URL, ICON_CLASS = "", TOGGLE_ICON = "fa fa-angle-left", ISOPEN_CLASS = "", }; db.CM_PERMISSIONS.Add(cM_PERMISSIONS); db.SaveChanges(); db.Entry(cM_PERMISSIONS).GetDatabaseValues(); //_localizationService.GetResource("Admin.Configuration.Stores.Added") SuccessNotification("New Permission has been Added"); //do activity log return(continueEditing ? RedirectToAction("Edit", new { PERMISSION_ID = cM_PERMISSIONS.PERMISSION_ID }) : RedirectToAction("Index")); } model.Permissions = new SelectList(db.CM_PERMISSIONS, "PERMISSION_ID", "PERMISSIONDESCRIPTION").ToList(); return(View(model)); }
public ActionResult Delete(int id) { if (!User.Identity.IsAuthenticated) { return(AccessDeniedView()); } var item = _permService.GetItembyId(id); if (item == null) { //No store found with the specified id return(RedirectToAction("List")); } try { //_permService.Delete(item); CM_PERMISSIONS cM_PERMISSIONS = db.CM_PERMISSIONS.Find(id); db.CM_PERMISSIONS.Remove(cM_PERMISSIONS); db.SaveChanges(); SuccessNotification("Admin.Configuration.Stores.Deleted"); return(RedirectToAction("List")); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("Edit", new { id = item.PERMISSION_ID })); } //CM_PERMISSIONS cM_PERMISSIONS = db.CM_PERMISSIONS.Find(id); //if (cM_PERMISSIONS == null) //{ // return HttpNotFound(); //} //return View(cM_PERMISSIONS); }
/// <summary> /// Gets a collection of membership users where the user name contains the specified user name to match. /// </summary> /// <returns> /// A <see cref="T:System.Web.Security.MembershipUserCollection"/> collection that contains a page of <paramref name="pageSize"/><see cref="T:System.Web.Security.MembershipUser"/> objects beginning at the page specified by <paramref name="pageIndex"/>. /// </returns> /// <param name="usernameToMatch">The user name to search for.</param><param name="pageIndex">The index of the page of results to return. <paramref name="pageIndex"/> is zero-based.</param><param name="pageSize">The size of the page of results to return.</param><param name="totalRecords">The total number of matched users.</param> internal bool DeletePermission(decimal p) { //ICollection<CM_USER_ROLE_XREF> UserRoleColl = new Collection<CM_USER_ROLE_XREF>(); // CM_USER_PROFILE up = new CM_USER_PROFILE(); //CM_USER_ROLE_XREF urx = new CM_USER_ROLE_XREF(); try { var PermxCount = (from Permx in db.CM_ROLE_PERM_XREF where Permx.PERMISSION_ID == p select Permx).Count(); if (PermxCount != null) { for (int i = 0; i < PermxCount; i++) { CM_ROLE_PERM_XREF objDelPermissionRoleRef = (from Permission in db.CM_ROLE_PERM_XREF where Permission.PERMISSION_ID == p select Permission).FirstOrDefault(); db.CM_ROLE_PERM_XREF.Remove(objDelPermissionRoleRef); db.SaveChanges(); } } CM_PERMISSIONS objDeletePermission = (from Perm in db.CM_PERMISSIONS where Perm.PERMISSION_ID == p select Perm).FirstOrDefault(); db.CM_PERMISSIONS.Remove(objDeletePermission); db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public bool getPermssn(string desc, string controller, string action, string URL) { bool status = false; string c = controller == string.Empty ? "Nill" : controller; string a = action == string.Empty ? "Nill" : action; CM_PERMISSIONS up = new CM_PERMISSIONS(); var count = (from n in db.CM_PERMISSIONS where n.PERMISSIONDESCRIPTION == desc && n.FORM_URL == URL && n.CONTROLLER_NAME == c && n.ACTION_NAME == a select n).Count(); //select new { n.PERMISSION_ID }; if (count > 0) { status = true; } else { status = false; } return(status); }
public bool CreatePermissions(string desc, string controller, string action, string formURL) { CM_PERMISSIONS up = new CM_PERMISSIONS(); up.PERMISSIONDESCRIPTION = desc; up.ACTION_NAME = action == string.Empty ? "Nill" : action; up.CONTROLLER_NAME = controller == string.Empty ? "Nill" : controller; up.FORM_URL = formURL == string.Empty ? "Nill" : formURL; up.ICON_CLASS = "Nill"; up.IMAGE_URL = "Nill"; up.ISACTIVE = true; up.ISOPEN_CLASS = "Nill"; up.PARENT_PERMISSION = 1; up.TOGGLE_ICON = "Nill"; db.CM_PERMISSIONS.Add(up); db.SaveChanges(); if (up.PERMISSION_ID == null) { return(false); } else { return(true); } }
public ActionResult DeleteConfirmed(decimal id) { CM_PERMISSIONS cM_PERMISSIONS = db.CM_PERMISSIONS.Find(id); db.CM_PERMISSIONS.Remove(cM_PERMISSIONS); db.SaveChanges(); return(RedirectToAction("Index")); }
//private AppDbContext db;// = new AppDbContext(); #endregion /// <summary> /// Inserts a new row in the CM_PERMISSIONS table. /// </summary> /// <param name="mdmque">A CM_PERMISSIONS object.</param> /// <returns>An updated CM_PERMISSIONS object.</returns> public CM_PERMISSIONS Insert(CM_PERMISSIONS permission) { using (var db = new AppDbContext()) { db.Set <CM_PERMISSIONS>().Add(permission); db.SaveChanges(); return(permission); } }
/// <summary> /// Updates an existing row in the userprofile table. /// </summary> /// <param name="permission">A userprofile entity object.</param> public void Update(CM_PERMISSIONS permission) { using (var db = new AppDbContext()) { var entry = db.Entry <CM_PERMISSIONS>(permission); // Re-attach the entity. entry.State = EntityState.Modified; db.SaveChanges(); } }
/// <summary> /// Updates the queitem /// </summary> /// <param name="queitem">queitem</param> public virtual void UpdateQueItem(CM_PERMISSIONS queitem) { if (queitem == null) { throw new ArgumentNullException("permission"); } _permissionsDAC.Update(queitem); //event notification //_eventPublisher.EntityUpdated(vendor); }
// GET: Permissions/Details/5 public ActionResult Details(decimal id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CM_PERMISSIONS cM_PERMISSIONS = db.CM_PERMISSIONS.Find(id); if (cM_PERMISSIONS == null) { return(HttpNotFound()); } return(View(cM_PERMISSIONS)); }