public override bool IsUserInRole(string username, string roleName)
 {
     using (var db = new GCMPDBEntities())
     {
         var user =
             db.Users.FirstOrDefault(
                 u => u.UserName.Equals(username, StringComparison.CurrentCultureIgnoreCase));
         if (user != null && user.Role.RoleName.Equals(roleName))
             return true;
         return false;
     }
 }
 public override string[] GetRolesForUser(string username)
 {
     using (var db = new GCMPDBEntities())
     {
         var user =
             db.Users.FirstOrDefault(
                 u => u.UserName.Equals(username, StringComparison.CurrentCultureIgnoreCase));
         if (user != null)
         {
             return new string[] { user.Role.RoleName };
         }
         return new string[] { };
     }
 }
Esempio n. 3
0
 //trungdd - constructor
 public CategoryModel()
 {
     db = new GCMPDBEntities();
 }
        public override bool ValidateUser(string username, string password)
        {
            User user;
            using (var db = new GCMPDBEntities())
            {
                user = db.Users.SingleOrDefault(u => u.UserName == username && u.Status.Equals(Const.UActive));
            }

            if (user != null)
            {
                String salt = user.KeyValue;
                String passAndSalt = password + salt;
                String hassedPass = AccountHelper.HashPassword(passAndSalt);
                if (hassedPass.Equals(user.Password))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
Esempio n. 5
0
 public CardModel()
 {
     _db = new GCMPDBEntities();
 }