public HttpResponseMessage ResetNewPassword(AppUserResetNewPasswordRequest newPasswordRequest) { if (newPasswordRequest == null) { ModelState.AddModelError("", "missing body data"); } if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } //returning a bool. service.nameofmethod(requestmodel) bool success = appUserService.ResetNewPassword(newPasswordRequest); if (success) { return(Request.CreateResponse(HttpStatusCode.OK, new SuccessResponse())); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse("There has been an issuse with your password"))); } //make response objects, like if password if }
public bool ResetNewPassword(AppUserResetNewPasswordRequest req) { AppUserResetPasswordResult resetPassResult = new AppUserResetPasswordResult(); string Password = BCrypt.HashPassword(req.PasswordHash); string FirstName = null; string Email = null; dataProvider.ExecuteNonQuery( "AppUser_ResetPassword", (parameters) => { parameters.AddWithValue("@PasswordHash", Password); parameters.AddWithValue("@ResetToken", req.ResetToken); parameters.Add("@FirstName", SqlDbType.NVarChar, 20).Direction = ParameterDirection.Output; parameters.Add("@Email", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output; }, (parameters) => { FirstName = parameters["@FirstName"].Value as string; Email = parameters["@Email"].Value as string; }); if (Email != null) { EmailSenderService.SendNewPasswordEmailConfirmation(FirstName, Email).Wait(); return(true); } else { return(false); } }