public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var    iconBytes = Convert.FromBase64String(model.IconBase64);
                var    container = AzureStorageFactory.GetBlobContainer("werewolfkill", true);
                string blobName  = string.Format("icon/{0}.png", HashValue.md5(iconBytes));
                var    user      = new ApplicationUser(model.Username)
                {
                    //UserName = model.Username,
                    NickName  = string.IsNullOrEmpty(model.Nickname) ? model.Username : model.Nickname,
                    AvatarUrl = string.Format("{0}/{1}", container.EndpointUrl, blobName)
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await container.UploadBlob(blobName, iconBytes);

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // 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);
                    // 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));
        }
        public async Task <ActionResult> ChangeIcon(ChangeIconViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var    iconBytes = Convert.FromBase64String(model.IconBase64);
            var    container = AzureStorageFactory.GetBlobContainer("werewolfkill", true);
            string blobName  = string.Format("icon/{0}.png", HashValue.md5(iconBytes));
            await container.UploadBlob(blobName, iconBytes);

            ViewData["Message"] = "Success";
            return(PartialView());
        }