public bool EmailIsInUse([EmailAddress]string email) { var hriService = new HriApiService(); return hriService.EmailIsInUse(email); }
public ActionResult ChangeEmail([Bind(Prefix = "changeEmailViewModel")] ChangeEmailViewModel model) { var user = Membership.GetUser(); var member = Services.MemberService.GetByUsername(user.UserName); if (!Membership.ValidateUser(user.UserName, model.Password)) { ModelState.AddModelError("changeEmailViewModel", IncorrectPassword); } if (!ModelState.IsValid) { return CurrentUmbracoPage(); } try { // Update Email with API var hriService = new HriApiService(); var apiUpdateSuccess = hriService.UpdateUserEmail(member, model.Email); // CMS should be updated only if API returns success if (apiUpdateSuccess) { // Set the user's email address to the new supplied email address. user.Email = model.Email; // Update the User profile in the database Membership.UpdateUser(user); } // Set the success flag to true TempData["IsSuccessful"] = true; return RedirectToCurrentUmbracoPage(); } catch (Exception ex) { logger.Error(ex); TempData["IsSuccessful"] = false; return RedirectToCurrentUmbracoPage(); } }