public ActionResult HandleEditProfile(ProfileViewModel model) { if (!ModelState.IsValid) { return CurrentUmbracoPage(); } //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); updateMember.Text = model.Name; updateMember.Email = model.EmailAddress; updateMember.getProperty("description").Value = model.Description; updateMember.getProperty("profileURL").Value = model.ProfileURL; updateMember.getProperty("twitter").Value = model.Twitter; updateMember.getProperty("linkedIn").Value = model.LinkedIn; updateMember.getProperty("skype").Value = model.Skype; //Save the member updateMember.Save(); //Update success flag (in a TempData key) TempData["IsSuccessful"] = true; //Return the view return RedirectToCurrentUmbracoPage(); }
public ActionResult RenderEditProfile() { ProfileViewModel profileModel = new ProfileViewModel(); //If user is logged in then let's pre-populate the model if (Member.IsLoggedOn()) { //Let's fill it up Member currentMember = Member.GetCurrentMember(); profileModel.Name = currentMember.Text; profileModel.EmailAddress = currentMember.Email; profileModel.MemberID = currentMember.Id; profileModel.Description = currentMember.getProperty("description").Value.ToString(); profileModel.ProfileURL = currentMember.getProperty("profileURL").Value.ToString(); profileModel.Twitter = currentMember.getProperty("twitter").Value.ToString(); profileModel.LinkedIn = currentMember.getProperty("linkedIn").Value.ToString(); profileModel.Skype = currentMember.getProperty("skype").Value.ToString(); } else { //They are not logged in, redirect to home return Redirect("/"); } //Pass the model to the view return PartialView("EditProfile", profileModel); }