Ejemplo n.º 1
0
 public JsonResult AccountCheck(RegisterView registerMember)
 {
     return Json(memberService.AccountCheck(registerMember.newMember.Account),
         JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 2
0
        public ActionResult Register(RegisterView registerMember)
        {
            if (ModelState.IsValid)
            {
                registerMember.newMember.Password = registerMember.Password;
                registerMember.newMember.AuthCode = mailService.GetValidationCode();

                memberService.Register(registerMember.newMember);
                //取得已寫好的Email範本
                string TempMail = System.IO.File.ReadAllText(Server.MapPath("~/Views/Shared/RegisterEmailTemplate.html"));
                UriBuilder ValidateUrl = new UriBuilder(Request.Url) {
                    Path=Url.Action("EmailValidate", "Members",
                    new { UserName=registerMember.newMember.Account,
                          Authcode= registerMember.newMember.AuthCode
                    })
                };
                string MailBody = mailService.GetReisterMailBody(TempMail,
                    registerMember.newMember.Name,
                    ValidateUrl.ToString().Replace("%3F", "?"));

                mailService.SendRegisterMail(MailBody, registerMember.newMember.Email);
                TempData["RegisterState"] = "註冊成功,請到信箱收信";
                return RedirectToAction("RegisterResult");
            }
            registerMember.Password = null;
            registerMember.PasswordCheck = null;
            return View(registerMember);
        }