//This method return All Permissions without checking user and other thing //It checks cache if list is in chache then it takes from cache else get all permission from db public static List <RbacPermission> GetAllPermissions() { List <RbacPermission> retList = (List <RbacPermission>)DanpheCache.Get("RBAC-Perms-All"); if (retList == null) { RbacDbContext dbContext = new RbacDbContext(connStringName); retList = dbContext.Permissions.ToList(); DanpheCache.Add("RBAC-Perms-All", retList, cacheExpiryMinutes); } return(retList); }
//This method returns all users details public static List <RbacUser> GetAllUsers() { List <RbacUser> retList = (List <RbacUser>)DanpheCache.Get("RBAC-Users-All"); if (retList == null) { RbacDbContext dbContext = new RbacDbContext(connStringName); retList = dbContext.Users.ToList(); DanpheCache.Add("RBAC-Users-All", retList, cacheExpiryMinutes); } return(retList); }
static void TestRoutes() { RbacDbContext dbContext = new RbacDbContext(connStr); List <DanpheRoute> allUserRoutes = RBAC.GetRoutesForUser(11); //below works fine.. //List<RbacUser> allUsers = dbContext.Users.ToList(); //List<RbacApplication> applications = dbContext.Applications.ToList(); //List<RbacPermission> permissions = dbContext.Permissions.ToList(); //List<RbacRole> roles = dbContext.Roles.ToList(); //List<DanpheRoute> routes = dbContext.Routes.ToList(); //List<UserRoleMap> userrolemaps = dbContext.UserRoleMaps.ToList(); //List<RolePermissionMap> rolePermMaps = dbContext.RolePermissionMaps.ToList(); }
public static RbacUser UpdateDefaultPasswordOfUser(string userName, string password, string confirmpassword) { RbacDbContext rbacDbcontxt = new RbacDbContext(connStringName); List <RbacUser> alluser = RBAC.GetAllUsers(); RbacUser usr = alluser.Where(a => a.UserName.ToLower() == userName.ToLower() && a.Password == EncryptPassword(password)) .Select(a => a).FirstOrDefault(); ////this condition is for that if user has enter wrong current password if (usr == null) { return(null); } else { usr.Password = EncryptPassword(confirmpassword); usr.ModifiedOn = DateTime.Now; usr.ModifiedBy = usr.EmployeeId; usr.NeedsPasswordUpdate = false; rbacDbcontxt.Entry(usr).State = EntityState.Modified; rbacDbcontxt.SaveChanges(); return(usr); } }