public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (NXtelData.Options.DisableAccountRegistration)
            {
                return(View("Error"));
            }
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                user.Mailbox = NXtelData.User.GetUniqueMailbox();
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var u = NXtelData.User.LoadByUserName(model.Email);
                    u.Mailbox = user.Mailbox;
                    string err;
                    NXtelData.User.Save(u, out err);
                    AuthenticationManager.SignOut();

                    // 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);
                    try
                    {
                        var    emailModel = new CallbackEmailModel(callbackUrl, u.Mailbox);
                        string body       = EmailController.RenderViewToString("Email", "ConfirmAccount", emailModel).Trim();
                        await UserManager.SendEmailAsync(user.Id, "Confirm your account", body);
                    }
                    catch
                    {
                        AuthenticationManager.SignOut();
                        ViewBag.NotLoggedIn = true;
                        return(View("Error"));
                    }
                    ViewBag.NotLoggedIn = true;
                    return(View("DisplayEmail"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }