public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, PhoneNumber = model.PhoneNumber, Email = model.Email}; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // Call service to register with auction service database var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); await proxy.AddServiceUserAsync(new Services.Models.User() { UserName = user.UserName, Email = user.Email, PhoneNumber = user.PhoneNumber }); proxy.Close(); // For more information on how to enable account confirmation and password reset please visit http://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); string msg = "Bạn đã đăng ký tài khoản tại SGUStore<br/>Vui lòng hoàn tất việc đăng ký của bạn <a href=\"" + callbackUrl + "\">tại đây</a>"; await UserManager.SendEmailAsync(user.Id, "SGUStore - Xác nhận đăng ký", msg); return RedirectToAction("Confirm", new { Email = user.Email }); } AddErrors(result); } // If we got this far, something failed, redisplay form return View(model); }