public static bool IsValidUser(string userName, string password)
        {
            //username is not case-sensitive but password is
            List <RbacUser> allUsrs = RBAC.GetAllUsers();
            RbacUser        usr     = allUsrs.Where(a => a.UserName.ToLower() == userName.ToLower() && a.Password == a.Password)
                                      .Select(a => a).FirstOrDefault();

            if (usr != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static RbacUser GetUser(int userId)
        {
            //username is not case-sensitive but password is
            List <RbacUser> allUsrs = RBAC.GetAllUsers();
            RbacUser        usr     = allUsrs.Where(a => a.UserId == userId)
                                      .Select(a => a).FirstOrDefault();

            //sending a clone so that my current object won't be modified outside.
            if (usr != null)
            {
                return((RbacUser)usr.Clone());
            }
            //don't clone if user is null (nullreferenceException)
            else
            {
                return(usr);
            }
        }
        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);
            }
        }