public ActionResult PostRegister(Register model) { if (ModelState.IsValid) { AccountProvider provider = new AccountProvider(); Account account = new Account(); account.CreateTime = DateTime.Now; account.Email = model.Email; account.Fullname = model.Fullname; account.IsActive = true; account.IsDeleted = false; account.IsLocked = false; account.Password = NDK.ApplicationCore.Extensions.Hepler.StringHelper.CreateMD5(model.Password); account.Role = RoleManager.Member; account.Username = model.Username; AccessEntityResult result = provider.Register(account); if (result.Status == AccessEntityStatusCode.OK) { TempData["Success"] = result.Message; return(RedirectToAction("Login")); } else { ModelState.AddModelError("registerError", result.Message); } } else { ModelState.AddModelError("registerError", MessageManager.GetErrorMessage(ModuleType.Register, MessageType.Register_ModelFailed)); } return(View("Register", model)); }
public async Task <ActionResult> Register(BLL.ViewModels.Identity.RegisterViewModel model) { if (ModelState.IsValid) { var result = await _accountProvider.Register(model); if (result.Succeeded) { // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }