public ActionResult Edit(CM_USER_ROLES cM_USER_ROLES, bool continueEditing) { ViewBag.CHECKERS = new SelectList(db.CM_USER_ROLES, "ROLE_ID", "ROLE_NAME"); if (!User.Identity.IsAuthenticated) { return(AccessDeniedView()); } var identity = ((CustomPrincipal)User).CustomIdentity; if (ModelState.IsValid) { cM_USER_ROLES.LAST_MODIFIED_DATE = DateTime.Now; cM_USER_ROLES.LAST_MODIFIED_BY = identity.Name; db.Entry(cM_USER_ROLES).State = EntityState.Modified; db.SaveChanges(); SuccessNotification("Role Updated"); return(continueEditing ? RedirectToAction("Edit", new { id = cM_USER_ROLES.ROLE_ID }) : RedirectToAction("Index")); //return RedirectToAction("Index"); } ViewBag.PARENT_ID = new SelectList(db.CM_USER_ROLES, "ROLE_ID", "ROLE_NAME"); //var userLevels = Enum.GetValues(typeof(CMdm.Entities.Domain.User.AuthorizationLevel)) // .Cast<CMdm.Entities.Domain.User.AuthorizationLevel>() // .Select(v => v.ToString()) // .ToList(); //List<AuthorizationLevelModel> userLevels = ((CMdm.Entities.Domain.User.AuthorizationLevel[])Enum.GetValues(typeof(CMdm.Entities.Domain.User.AuthorizationLevel))).Select(c => new AuthorizationLevelModel() { Value = (int)c, Name = c.ToString() }).ToList(); ViewBag.USER_LEVELS = new SelectList(db.CM_AUTH_LEVELS, "LEVEL_ID", "LEVEL_NAME"); return(View(cM_USER_ROLES)); }
private void GetDatabaseUserRolesPermissions() { using (AppDbContext _data = new AppDbContext()) { CM_USER_PROFILE _user = _data.CM_USER_PROFILE.Where(u => u.USER_ID.ToUpper() == this.UserId.ToUpper()).FirstOrDefault(); if (_user != null) { this.ProfileId = (int)_user.PROFILE_ID; CM_USER_ROLES _userRole = _data.CM_USER_ROLES.Where(u => u.ROLE_ID == this.RoleId).FirstOrDefault(); List <CM_ROLE_PERM_XREF> _permxref = _data.CM_ROLE_PERM_XREF.Where(p => p.ROLE_ID == _userRole.ROLE_ID).ToList(); foreach (CM_ROLE_PERM_XREF _permission in _permxref) { //_userRole.CM_PERMISSIONS.Add(new CM_PERMISSIONS { PERMISSION_ID = (int)_permission.PERMISSION_ID, PERMISSIONDESCRIPTION = _permission.PERMISSIONDESCRIPTION }); Permissions.Add(new CM_PERMISSIONS { PERMISSION_ID = (int)_permission.PERMISSION_ID, PERMISSIONDESCRIPTION = "" }); } this.Roles.Add(_userRole); //foreach (CM_USER_ROLES _role in _user.CM_USER_ROLES) //{ // UserRole _userRole = new UserRole { Role_Id = _role.ROLE_ID, RoleName = _role.ROLE_NAME }; // this.Roles.Add(_userRole); // //if (!this.IsSysAdmin) // // this.IsSysAdmin = (bool)!_role.IS_DEFAULT; //} } } }
public ActionResult DeleteConfirmed(int id) { ViewBag.CHECKERS = new SelectList(db.CM_USER_ROLES, "ROLE_ID", "ROLE_NAME"); CM_USER_ROLES cM_USER_ROLES = db.CM_USER_ROLES.Find(id); db.CM_USER_ROLES.Remove(cM_USER_ROLES); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Roles/Details/5 public ActionResult Details(int?id) { ViewBag.CHECKERS = new SelectList(db.CM_USER_ROLES, "ROLE_ID", "ROLE_NAME"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CM_USER_ROLES cM_USER_ROLES = db.CM_USER_ROLES.Find(id); if (cM_USER_ROLES == null) { return(HttpNotFound()); } return(View(cM_USER_ROLES)); }
public bool getRole(string p) { bool status = false; CM_USER_ROLES rl = new CM_USER_ROLES(); var count = from n in db.CM_USER_ROLES where n.ROLE_NAME == p.ToString() select new { n.ROLE_ID }; if (count.Count() > 0) { status = true; } else { status = false; } return(status); }
public bool CreateRole(string roleName) { //CDMA_Model mdb = new CDMA_Model(); CM_USER_ROLES rl = new CM_USER_ROLES(); rl.ROLE_NAME = roleName; rl.PSWD_LIFE_DAYS = 90; rl.CREATED_DATE = DateTime.Now; rl.CREATED_BY = "admin"; db.CM_USER_ROLES.Add(rl); db.SaveChanges(); if (rl.ROLE_ID == null) { return(false); } else { return(true); } }
public ActionResult Create([Bind(Exclude = "ROLE_ID")] CM_USER_ROLES cM_USER_ROLES, bool continueEditing) { ViewBag.CHECKERS = new SelectList(db.CM_USER_ROLES, "ROLE_ID", "ROLE_NAME"); if (!User.Identity.IsAuthenticated) { return(AccessDeniedView()); } var identity = ((CustomPrincipal)User).CustomIdentity; if (ModelState.IsValid) { cM_USER_ROLES.CREATED_BY = identity.Name; cM_USER_ROLES.CREATED_DATE = DateTime.Now; db.CM_USER_ROLES.Add(cM_USER_ROLES); db.SaveChanges(); db.Entry(cM_USER_ROLES).GetDatabaseValues(); SuccessNotification("Role Created"); return(continueEditing ? RedirectToAction("Edit", new { id = cM_USER_ROLES.ROLE_ID }) : RedirectToAction("Index")); //return RedirectToAction("Index"); } ViewBag.PARENT_ID = new SelectList(db.CM_USER_ROLES, "ROLE_ID", "ROLE_NAME"); ViewBag.USER_LEVELS = new SelectList(db.CM_AUTH_LEVELS, "LEVEL_ID", "LEVEL_NAME"); return(View(cM_USER_ROLES)); }