public void SetCredentialsFromDataBase(string login, string password) { var systemOperatorDAO = new SystemOperatorDAO(); var result = systemOperatorDAO.SystemOperators().FirstOrDefault( x => x.Login == login && x.Password == password); this.Name = result.Name; this.Password = result.Password; this.Role = result.Role; this.RegistryDate = result.RegistryDate; this.Id = result.Id; }
internal bool Authenticate(string login, string password) { if (string.IsNullOrWhiteSpace(login)) { throw new ArgumentNullException(nameof(login)); } if (string.IsNullOrWhiteSpace(password)) { throw new ArgumentNullException(nameof(password)); } var systemOperatorDAO = new SystemOperatorDAO(); var result = systemOperatorDAO.SystemOperators().FirstOrDefault( x => x.Login == login && x.Password == password); if (result != null) { return(true); } else { throw new ArgumentException("Invalid Credentials"); } }