public ActionResult MemberEditProfile(MemberEditProfileModel model) { if (ModelState.IsValid) { var memberService = Services.MemberService; var member = Members.GetCurrentMember(); // Get an editable curMember var curMember = memberService.GetById(member.Id); // save their password if they provide an update if (!(string.IsNullOrEmpty(model.Password)) && model.Password == model.Password2) { if (model.Password.Length >= 8 && model.Password.Length <= 36) { memberService.SavePassword(curMember, model.Password); } else { TempData["Status"] = "Your new password must be between 8 and 36 characters long"; return(RedirectToCurrentUmbracoPage()); } } curMember.SetValue("firstName", model.FirstName); curMember.SetValue("lastName", model.LastName); // if you were to change the members email address you'd want to validate it first // TODO // here you should do your Mailchimp integration / or whatever curMember.SetValue("mailingListInclude", model.MailingListInclude); // remember to save memberService.Save(curMember); @TempData["Success"] = true; TempData["Status"] = "Your account has been updated"; return(RedirectToCurrentUmbracoPage()); } else { // model is invalid TempData["Status"] = "Please ensure you've provided all the required information."; return(CurrentUmbracoPage()); } }
public ActionResult Edit(MemberEditProfileModel model) { var memberId = MemberSession.GetMemberId(); if (ModelState.IsValid) { byte[] array = null; if (model.Avatar != null) { using (MemoryStream ms = new MemoryStream()) { model.Avatar.InputStream.Position = 0; model.Avatar.InputStream.CopyTo(ms); array = ms.GetBuffer(); } } Members.EditProfile(memberId, model.Nickname, array, model.Faculty, model.DateOfBirth, model.Status, model.Phone, model.Facebook, model.LinkedIn, model.Skype); } return(RedirectToAction("Profile", new { id = memberId })); }
public ActionResult Edit() { var model = MemberEditProfileModel.Load(MemberSession.GetMemberId()); return(View(model)); }