コード例 #1
0
        public ActionResult PasswordReset(PasswordResetModel passwordReset)
        {
            using (db = new StateScholarshipEntities())
            {
                string id = Session["userid"].ToString();

                if (id != null)
                {
                    if (passwordReset.NewPassword != null && passwordReset.ConfirmPassword != null)
                    {
                        int userid = int.Parse(Session["userid"].ToString());

                        var UserIdCheck = db.Registration1.Where(d => d.User_id == userid).FirstOrDefault();

                        UserIdCheck.user_password = passwordReset.NewPassword;

                        db.SaveChanges();

                        ViewBag.SuccessMessage = "Password Updated successful";
                    }

                    else
                    {
                        ViewBag.Message = "Please enter Details";
                    }
                }

                else
                {
                    return(RedirectToAction("Login"));
                }

                return(View());
            }
        }
        public ActionResult Create([Bind(Include = "User_id,FirstName,LastName,DateofBirth,Gender,Contact,Email,User_category,user_password,FavouritePet,FavouriteMovie,LuckyNumber,approvedByProvider,approvedByInstitution")] Registration registration)
        {
            var checkId = db.Registrations.Where(x => x.User_id == registration.User_id).FirstOrDefault();

            if (checkId == null)
            {
                if (ModelState.IsValid)
                {
                    db.Registrations.Add(registration);
                    db.SaveChanges();
                    return(RedirectToAction("Successfull"));
                }
            }
            else
            {
                ViewBag.Message = "User Id Already Exists, Please Enter another User ID";
                return(View());
            }


            return(View(registration));
        }