Example #1
0
        public HttpResponseMessage CreateNewPassword(UserNewPasswordModelClass modelnewpasswordData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var db = new MvcTutorialEntities())
                    {
                        var verify = db.tblUser.Find(modelnewpasswordData.UserID);
                        if (verify != null)
                        {
                            verify.Password = modelnewpasswordData.NewPassword;
                            db.SaveChanges();

                            return(this.GenerateResponse(true, HttpStatusCode.OK, Constants.NEWPASSWORD));
                        }
                        else
                        {
                            return(this.GenerateResponse(false, HttpStatusCode.Unauthorized, Constants.UNOTHORIZED));
                        }
                    }
                }
                else
                {
                    return(this.GenerateResponse(false, HttpStatusCode.NotFound, Constants.NODATA));
                }
            }
            catch (Exception ex)
            {
                return(this.GenerateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
        public ActionResult CreateNewPassword(UserNewPasswordModelClass modelnewpasswordData)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MvcTutorialEntities())
                {
                    var UserID = Convert.ToInt32(Session["ForgotPassword"]);
                    var verify = db.tblUser.Find(UserID);
                    if (verify != null)
                    {
                        verify.Password = modelnewpasswordData.NewPassword;
                        db.SaveChanges();
                        ViewBag.SuccessMessage = "New Password Created Successfully. Please Re-Login with New Password.";
                        Session.RemoveAll();
                        return(Json(new { msg = "success" }, JsonRequestBehavior.AllowGet));

                        //return RedirectToAction("Login", "User");
                    }
                }
            }
            return(View());
        }