コード例 #1
0
        //
        // Get: /Manage/UpdateBiography
        public async Task <ActionResult> UpdateBiography()
        {
            var userId = User.Identity.GetUserId();
            var updateBiographyViewModel = new UpdateBiographyViewModel()
            {
                Biography     = await UserManager.GetBiographyAsync(userId),
                ProfilePicUrl = await UserManager.GetProfilePicUrlAsync(userId)
            };

            return(View(updateBiographyViewModel));
        }
コード例 #2
0
        public async Task <ActionResult> UpdateBiography(UpdateBiographyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            if (user != null)
            {
                user.Biography     = model.Biography;
                user.ProfilePicUrl = await UploadImageAsync(model.ProfilePicUrl, model.ProfilePicture) ?? user.ProfilePicUrl;

                await UserManager.UpdateAsync(user);
            }
            return(RedirectToAction("Index", new { Message = ManageMessageId.UpdateBiographySuccess }));
        }