public async Task<ActionResult> Index(ManageMessageId? message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.Error ? "An error has occurred."
                : "";

            var userId = User.Identity.GetUserId();
            var model = new IndexViewModel
            {
                HasPassword = HasPassword(),
                Logins = await UserManager.GetLoginsAsync(userId)
            };

            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
            model.Avatar = user.Avatar;
            model.FullName = user.FullName;

            return View(model);
        }
        public async Task<ActionResult> Index(IndexViewModel model, HttpPostedFileWrapper upload)
        {
            Console.WriteLine(ModelState);
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                user.FullName = model.FullName;

                if (upload != null && upload.ContentLength > 0 && upload.ContentLength < 8*1024*1024 && upload.ContentType.Contains("image/"))
                {
                    var avatar = new FileModel
                    {
                        FileName = Guid.NewGuid() + Path.GetExtension(upload.FileName),
                        FileType = FileType.Avatar,
                        ContentType = upload.ContentType
                    };
                    using (var reader = new BinaryReader(upload.InputStream))
                    {
                        avatar.Content = reader.ReadBytes(upload.ContentLength);
                    }
                    user.Avatar = avatar;
                }

                var result = await UserManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    return RedirectToAction("Index");
                }

                AddErrors(result);
            }

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