public ActionResult Render() { var ms = Services.MemberService; var mem = ms.GetById(Members.GetCurrentMemberId()); var m = new ProfileModel(); m.Name = mem.Name; m.Email = mem.Email; m.Bio = mem.GetValue<string>("profileText"); m.Location = mem.GetValue<string>("location"); m.Company = mem.GetValue<string>("company"); m.TwitterAlias = mem.GetValue<string>("twitter"); m.Avatar = mem.GetValue<string>("avatar"); return PartialView("~/Views/Partials/Members/Profile.cshtml", m); }
public ActionResult HandleSubmit(ProfileModel model) { if (!ModelState.IsValid) return CurrentUmbracoPage(); var ms = Services.MemberService; var mem = ms.GetById(Members.GetCurrentMemberId()); if (mem.Email != model.Email && ms.GetByEmail(model.Email) != null) { ModelState.AddModelError("Email", "A Member with that email already exists"); return CurrentUmbracoPage(); } if(model.Password != model.RepeatPassword) { ModelState.AddModelError("Password", "Passwords need to match"); ModelState.AddModelError("RepeatPassword", "Passwords need to match"); return CurrentUmbracoPage(); } mem.Name = model.Name ; mem.Email = model.Email; mem.Username = model.Email; mem.SetValue("profileText",model.Bio); mem.SetValue("location",model.Location); mem.SetValue("company",model.Company); mem.SetValue("twitter",model.TwitterAlias); mem.SetValue("avatar", model.Avatar); ms.Save(mem); var avatarImage = Utils.GetMemberAvatarImage(Members.GetById(mem.Id)); if (avatarImage != null && (avatarImage.Width < 400 || avatarImage.Height < 400)) { ModelState.AddModelError("Avatar", "Please upload an avatar that is at least 400x400 pixels"); return CurrentUmbracoPage(); } if(!string.IsNullOrEmpty(model.Password) && !string.IsNullOrEmpty(model.RepeatPassword) && model.Password == model.RepeatPassword) ms.SavePassword(mem, model.Password); TempData["success"] = true; return RedirectToCurrentUmbracoPage(); }
public ActionResult HandleSubmit(ProfileModel model) { if (!ModelState.IsValid) return CurrentUmbracoPage(); var ms = Services.MemberService; if (ms.GetByEmail(model.Email) != null) { ModelState.AddModelError("Email", "A Member with that email already exists"); return CurrentUmbracoPage(); } if (model.Password != model.RepeatPassword) { ModelState.AddModelError("Password", "Passwords need to match"); ModelState.AddModelError("RepeatPassword", "Passwords need to match"); return CurrentUmbracoPage(); } var mem = ms.CreateMemberWithIdentity(model.Email, model.Email, model.Name, "member"); mem.SetValue("profileText", model.Bio); mem.SetValue("location", model.Location); mem.SetValue("company", model.Company); mem.SetValue("twitter", model.TwitterAlias); mem.SetValue("avatar", model.Avatar); ms.AssignRole(mem.Username, "standard"); ms.Save(mem); ms.SavePassword(mem, model.Password); Members.Login(model.Email, model.Password); return Redirect("/"); }