Beispiel #1
0
        public bool Create(string username, string password, string email)
        {
            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(email))
            {
                return(false);
            }

            try
            {
                var user = new User
                {
                    Name     = username,
                    Password = HashPassword.GetHashSha256(password),
                };

                this.db.Users.Add(user);
                this.db.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #2
0
        public User UserExists(string username, string password)
        {
            User user  = null;
            var  users = this.db.Users.AsQueryable();

            user = users
                   .AsEnumerable()
                   .FirstOrDefault(t => t.Name == username && t.Password == HashPassword.GetHashSha256(password));
            //return this.db
            //    .Users
            //    .Any(u => u.Username == username && u.Password == HashPassword.GetHashSha256(password));
            return(user);
        }
 public bool UserExists(string username, string password)
 => this.db
 .Users
 .Any(u => u.Username == username && u.Password == HashPassword.GetHashSha256(password));