示例#1
0
        private bool Check_log_in(string login, string password)
        {
            bool result;

            using BrainlyContext db = new BrainlyContext();
            OperatorWorkspace user = db.OperatorsWorkspace.Where(op => op.Login == login).FirstOrDefault();

            if (user != null)
            {
                if (user.Password == Hash.HashMD5(password))
                {
                    User_info.Current_status = user.IsAdmin ? User_info.Status.Admin : User_info.Status.Operator;
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
示例#2
0
 private void ExecuteAdd_registration(string login, string password)
 {
     using BrainlyContext db = new BrainlyContext();
     db.OperatorsWorkspace.Add(new OperatorWorkspace(login, password));
     try
     {
         db.SaveChanges();
         label_result.Text = "Registration has finished successfully";
     }
     catch (DbUpdateException ex)
     {
         PostgresException postgresException = (PostgresException)ex.InnerException;
         if (postgresException.SqlState == "23505")
         {
             label_result.Text = string.Format("User with the login \"{0}\" already exist. {1}", login, ex.Message);
         }
     }
 }