Exemple #1
0
        public ActionResult CheckEmail(string email = "")
        {
            UserViewModel  data   = UserRepo.CheckEmail(email);
            ResponseResult result = new ResponseResult();

            if (data.email != null)
            {
                result.Success = false;
            }
            return(Json(new
            {
                success = result.Success
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public ActionResult ForgotPassword(string email = "")
        {
            UserViewModel  data   = UserRepo.CheckEmail(email);
            ResponseResult result = new ResponseResult();

            if (data.email != null)
            {
                result = HomeRepo.ForgotPassword(data);
            }
            else
            {
                result.Success      = false;
                result.ErrorMessage = "Email tidak ditemukan";
            }
            return(Json(new
            {
                success = result.Success,
                message = result.ErrorMessage,
                entity = result.Entity
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Register(RegisterModel userModel)
        {
            //using (UsersEntities dbmodel = new UsersEntities())
            //{
            //    if (dbmodel.UserAccounts.Any(x => x.Email == userModel.Email))
            //    {
            //        return View("SignUpFailed");
            //    }
            //    UserAccount user = new UserAccount();
            //    userModel.UserID = Guid.NewGuid();
            //    userModel.DateRegister = DateTime.Now;
            //    userModel.Password = PasswordEncryption.textToEncrypt(userModel.Password);
            //    BuildEmailTemplate(userModel.UserID);
            //    dbmodel.UserAccounts.Add(userModel);
            //    dbmodel.SaveChanges();
            //    ModelState.Clear();
            //    return View("SignUp", user);
            //}
            if (ModelState.IsValid)
            {
                UserRepo user = new UserRepo();

                if (user.CheckEmail(userModel.Email))
                {
                    userModel.Password = PasswordEncryption.textToEncrypt(userModel.Password);
                    user.saveAtLogin(userModel);
                    EmailBuilder.BuildEmailTemplateForNewUser(userModel.UserID);
                    string msg = "An Account Activation Request has been sent to your Email, kindly check your Email`3301`";
                    return(RedirectToAction("SignUp", "Account", new { msg }));
                }
                else
                {
                    return(View("SignUpFailed"));
                }
            }
            return(View());
        }