Ejemplo n.º 1
0
 public IHttpActionResult EditPassword([FromBody] m_Users_Password request, int Id)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (_Users.Checkpassword(request.old_password))
             {
                 var qry = _Users.UserEditPassword(request, Id);
                 if (qry != null)
                 {
                     return(Json(qry));
                 }
                 return(BadRequest("Create user failed."));
             }
             else
             {
                 return(BadRequest("Old password incorrect."));
             }
         }
         catch (Exception ex)
         {
             return(BadRequest(ex.Message));
         }
     }
     return(BadRequest("Model is incorrect."));
 }
Ejemplo n.º 2
0
        public users UserEditPassword(m_Users_Password request, int Id)
        {
            request.new_password = Convert.ToBase64String(Encoding.UTF8.GetBytes(request.new_password));
            var qry = db.Database.SqlQuery <users>("EXEC [farmnet].[s_Users_Edit_Password] @Id,@password",
                                                   new SqlParameter("@Id", Id),
                                                   new SqlParameter("@password", request.new_password)
                                                   ).FirstOrDefault();

            if (qry != null)
            {
                return(qry);
            }
            return(null);
        }