public ActionResult RenderEditProfile() { ProfileViewModel profileModel = new ProfileViewModel(); var membershipService = ApplicationContext.Services.MemberService; //If user is logged in then let's pre-populate the model if (Members.IsLoggedIn()) { //Let's fill it up var currentMember = membershipService.GetById(Members.GetCurrentMemberId()); profileModel.Name = currentMember.Name; profileModel.EmailAddress = currentMember.Email; profileModel.MemberID = currentMember.Id; /* profileModel.Description = currentMember.Properties["description"].Value.ToString(); profileModel.ProfileURL = currentMember.Properties["profileURL"].Value.ToString(); profileModel.Twitter = currentMember.Properties["twitter"].Value.ToString(); profileModel.LinkedIn = currentMember.Properties["linkedIn"].Value.ToString(); profileModel.Skype = currentMember.Properties["skype"].Value.ToString(); * */ } else { //They are not logged in, redirect to home return Redirect("/"); } //Pass the model to the view return PartialView("EditProfile", profileModel); }
public ActionResult HandleEditProfile(ProfileViewModel model) { var membershipService = ApplicationContext.Services.MemberService; if (!ModelState.IsValid) { return CurrentUmbracoPage(); //PartialView("EditProfile", model); } //Update the member with our data & save it down //Using member ID and not email address in case member has changed their email // Member updateMember = new Member(model.MemberID); var updateMember = membershipService.GetById(Members.GetCurrentMemberId()); updateMember.Name = model.Name; updateMember.Email = model.EmailAddress; /* updateMember.Properties["description"].Value = model.Description; updateMember.Properties["profileURL"].Value = model.ProfileURL; updateMember.Properties["twitter"].Value = model.Twitter; updateMember.Properties["linkedIn"].Value = model.LinkedIn; updateMember.Properties["skype"].Value = model.Skype; */ //Save the member membershipService.Save(updateMember); //Update success flag (in a TempData key) TempData["IsSuccessful"] = true; //Return the view //return PartialView("EditProfile", model); //Return the view return RedirectToCurrentUmbracoPage(); }