Beispiel #1
0
        public ActionResult Registration(UserInfo user)
        {
            if (ModelState.IsValid)
            {
                var hash = Crypto.HashPassword(user.Password);

                DbUsers dbuser = new DbUsers();
                dbuser.FirstName   = user.FirstName;
                dbuser.LastName    = user.LastName;
                dbuser.EmailID     = user.EmailID;
                dbuser.Password    = hash;
                dbuser.PhoneNumber = user.PhoneNumber;
                dbuser.UserName    = user.UserName;


                DatabaseConnection dbconnect = new DatabaseConnection();

                ReturnCode.result result = dbconnect.UserRegistration(dbuser);


                if (result.Equals(ReturnCode.result.fail))
                {
                    ModelState.AddModelError("CustomError", "Registration not Successful.Please try later");
                    return(View());
                }
                else if (result.Equals(ReturnCode.result.userexist))
                {
                    ModelState.AddModelError("CustomError", "EmailID/UserName already exist");
                    return(View());
                }
                else if (result.Equals(ReturnCode.result.success))
                {
                    ViewBag.Message = "Registration successful.Please login";
                    return(RedirectToAction("Login"));
                }
            }
            return(View(user));
        }
Beispiel #2
0
        public ActionResult ForgetPassword(LoggedinInfo user)
        {
            var     hash   = Crypto.HashPassword(user.Password);
            DbUsers dbuser = new DbUsers();

            dbuser.UserName = user.UserName;
            dbuser.Password = hash;
            if (ModelState.IsValid)
            {
                DatabaseConnection dbconnect = new DatabaseConnection();
                ReturnCode.result  result    = dbconnect.changePassword(dbuser);
                if (result.Equals(ReturnCode.result.success))
                {
                    TempData["Message"] = "Password has been changed.Please Login";
                    return(RedirectToAction("Login"));
                }
                else
                {
                    ModelState.AddModelError("CustomError", "Password has not been changed");
                    return(View());
                }
            }
            return(View());
        }