Esempio n. 1
0
        public ActionResult EditProfile(Guid id, FormCollection form)
        {
            UserProfile userProfile = UserProfileManager.GetByID(id);
            UpdateModel<UserProfile>(userProfile, "UserProfile");

            //This object represents a file the user has uploaded...
            UploadFilePartialViewModel file = new UploadFilePartialViewModel();
            UpdateModel<UploadFilePartialViewModel>(file);

            UploadImagePopupViewModel uploadImagePopupViewModel = new UploadImagePopupViewModel();
            UpdateModel<UploadImagePopupViewModel>(uploadImagePopupViewModel);

            if (uploadImagePopupViewModel.ImageMetaData != null)
            {
                userProfile.ProfileImage = uploadImagePopupViewModel.ImageMetaData;
            }

            //Here we can implement the specifics of handling our file...
            IListenToUser user = (IListenToUser)this.HttpContext.User;

            try
            {
                UserProfileManager.Save(userProfile, user.UserCredentials);
            }
            catch (ValidationException e)
            {
                e.AddToModelState(ViewData.ModelState, "UserProfile");
            }

            //If the model isnt valid
            if (!ViewData.ModelState.IsValid)
            {
                EditProfileViewModel editProfileViewModel = new EditProfileViewModel();
                editProfileViewModel.UserProfile = userProfile;
                editProfileViewModel.StyleSummaries = StyleManager.GetStyleSummaries(this.GetSite().ID);

                return View(editProfileViewModel);
            }

            return RedirectToWhoIs(userProfile);
        }
Esempio n. 2
0
        public ActionResult EditProfile(Guid id)
        {
            UserProfile userProfile = UserProfileManager.GetByID(id);
            RedirectUserIfAccessDenied(userProfile);

            EditProfileViewModel editProfileViewModel = new EditProfileViewModel();
            editProfileViewModel.UserProfile = userProfile;
            editProfileViewModel.StyleSummaries = StyleManager.GetStyleSummaries(this.GetSite().ID);

            editProfileViewModel.UploadImagePopupViewModel = new UploadImagePopupViewModel();
            editProfileViewModel.UploadImagePopupViewModel.ImageMetaData = userProfile.ProfileImage;

            return View(editProfileViewModel);
        }