public virtual ActionResult IsEmailAvailable(string email) { var membershipUser = _membershipUserProvider.QueryUserByEmail(Membership, email); if (membershipUser != null) { return(Json(string.Format("{0} is duplicate.".Localize(), email), JsonRequestBehavior.AllowGet)); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public virtual MembershipUser Create(Kooboo.CMS.Membership.Models.Membership membership, string userName, string email, string password, bool isApproved, string culture, string timeZoneId, string passwordQuestion = null, string passwordAnswer = null, string[] membershipGroups = null, Dictionary <string, string> profiles = null, string comment = null) { membership = membership.AsActual(); MembershipUser membershipUser = new MembershipUser() { Membership = membership }; membershipUser.UserName = userName; List <DataViolationItem> violations = new List <DataViolationItem>(); if (membershipUser.AsActual() != null) { violations.Add(new DataViolationItem("UserName", userName, "DuplicateUserName")); } if (_provider.QueryUserByEmail(membership, email) != null) { violations.Add(new DataViolationItem("Email", email, "DuplicateEmail")); } if (violations.Count > 0) { throw new DataViolationException(violations); } if (!string.IsNullOrEmpty(email)) { membershipUser.Email = email; } membershipUser.Culture = culture; membershipUser.TimeZoneId = timeZoneId; membershipUser.PasswordQuestion = passwordQuestion; membershipUser.PasswordAnswer = passwordAnswer; membershipUser.Comment = comment; membershipUser.IsApproved = isApproved; if (!membershipUser.IsApproved) { string activateCode = UniqueIdGenerator.GetInstance().GetBase32UniqueId(10); membershipUser.ActivateCode = activateCode; } membershipUser.UtcCreationDate = DateTime.UtcNow; membershipUser.Profiles = profiles; membershipUser.MembershipGroups = membershipGroups; SetPassword(membership, membershipUser, password); _provider.Add(membershipUser); return(_provider.Get(membershipUser)); }