示例#1
0
        public bool UpdateUserPassword(int userId, UserPasswordsDTO passwords)
        {
            bool     result  = false;
            ISession session = null;

            try
            {
                session = DataLayer.GetSession();
                User user = session.Load <User>(userId);
                if (user.Password != passwords.OldPassword)
                {
                    throw new Exception("WrongPassword");
                }
                user.Password = passwords.NewPassword;
                session.SaveOrUpdate(user);
                session.Flush();
                session.Close();
                result = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (session != null)
                {
                    session.Close();
                }
            }
            return(result);
        }
示例#2
0
 public bool UpdateUserPassword(int id, UserPasswordsDTO passwords)
 {
     return(userDataAccess.UpdateUserPassword(id, passwords));
 }
示例#3
0
 public bool Put(int id, [FromBody] UserPasswordsDTO passwords)
 {
     service = Service.UserService;
     return(service.UpdateUserPassword(id, passwords));
 }