public IHttpActionResult ChangePassword(CUSTOM_CHANGE_PASSWORD changePassword) { ApiResData res = new ApiResData(); try { if (!ModelState.IsValid) { rs.SetErrorStatus(eFunc.fg.SFailed); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.DataNf, new Exception(eFunc.fg.DataIsntValid))); return(Content(HttpStatusCode.NotFound, resObj)); } rs = repo.ChangePassword(changePassword.IdUser, changePassword.OldPassword, changePassword.NewPassword); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf))); return(Content(HttpStatusCode.BadRequest, resObj)); } }
public ActionResult ActionChangePassword(CUSTOM_CHANGE_PASSWORD changePassword) { try { changePassword.IdUser = CurrentUser.GetCurrentUserIdId(); rs = JsonConvert.DeserializeObject <ResultStatus>(ParsingObject.RequestData(changePassword, "User", "ChangePassword", EnumList.IHttpMethod.Post.ToString())); if (rs.IsSuccess) { TempData["msgSuccess"] = rs.MessageText; } else { TempData["msgError"] = rs.MessageText; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); rs.SetErrorStatus("Data failed to changed"); TempData["msgError"] = rs.MessageText; } return(RedirectToAction("ChangePassword")); }