Beispiel #1
0
        public async Task <ActionResult> UpdateAvatar(ProfileAvatarModel model)
        {
            if (ModelState.IsValid)
            {
                var deletefilename = "";

                var responseUser = await WepApiMethod.SendApiAsync <DetailsUserModel>(HttpVerbs.Get, $"Administration/User?id={CurrentUser.UserId}");

                if (responseUser.isSuccess)
                {
                    deletefilename = responseUser.Data.AvatarImageUrl;
                }

                var filename = FileMethod.SaveFile(model.AvatarFile, Server.MapPath("~/img/avatar"), deletefilename);

                var response = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Put, $"Home/Profile/UpdateAvatar?id={CurrentUser.UserId}&imageUrl={filename}");

                if (response.isSuccess)
                {
                    await LogActivity(Modules.Setting, "Change Avatar Photo");

                    TempData["SuccessMessage"] = Language.Profile.AlertSuccessUpdateAvatar;

                    return(RedirectToAction("MyProfile", "Home", new { area = "" }));
                }
            }

            TempData["ErrorMessage"] = Language.Profile.AlertFailUpdateAvatar;

            return(View(model));
        }
Beispiel #2
0
        public async Task <ActionResult> UpdateAvatar()
        {
            var response = await WepApiMethod.SendApiAsync <DetailsUserModel>(HttpVerbs.Get, $"Administration/User?id={CurrentUser.UserId}");

            var model = new ProfileAvatarModel();

            if (response.isSuccess)
            {
                model.AvatarImageUrl = response.Data.AvatarImageUrl;
            }

            return(View(model));
        }