public virtual RenderJsonResult RegisterNewProfile(RegisterNewProfileParameters parameters, bool ignoreMatches)
        {
            if (!parameters.AreValid())
            {
                return(this.RenderJsonErrorCode(1, "Invalid Parameters"));
            }
            if (!ignoreMatches)
            {
                var possibleMatchingProfiles = DocumentSession.Query <DirectoryProfile>()
                                               .Where(x => x.FirstName.StartsWith(parameters.FirstName.Take(3)))
                                               .Where(x => x.LastName.StartsWith(parameters.LastName.Take(3)))
                                               .Take(5)
                                               .ToList();
                if (possibleMatchingProfiles.Any())
                {
                    return(this.RenderJsonErrorCode(2, "Possible Existing Profiles", possibleMatchingProfiles.Select(x => new {
                        firstName = x.FirstName,
                        lastName = x.LastName,
                        emailAddress = x.EmailAddress,
                    }).ToArray()));
                }
            }
            var newProfile = DirectoryProfile.RegisterNewProfile(parameters);

            DocumentSession.Store(newProfile);
            return(this.RenderJsonSuccessErrorCode());
        }
 public static DirectoryProfile RegisterNewProfile(RegisterNewProfileParameters parameters)
 {
     return new DirectoryProfile(parameters.EmailAddress, parameters.FirstName, parameters.LastName) {
         PhoneNumber = parameters.PhoneNumber,
         GraduationYear = parameters.GraduationYear,
         Major = parameters.Major,
     };
 }
 public virtual RenderJsonResult RegisterNewProfile(RegisterNewProfileParameters parameters, bool ignoreMatches)
 {
     if (!parameters.AreValid()) {
         return this.RenderJsonErrorCode(1, "Invalid Parameters");
     }
     if (!ignoreMatches) {
         var possibleMatchingProfiles = DocumentSession.Query<DirectoryProfile>()
             .Where(x => x.FirstName.StartsWith(parameters.FirstName.Take(3)))
             .Where(x => x.LastName.StartsWith(parameters.LastName.Take(3)))
             .Take(5)
             .ToList();
         if (possibleMatchingProfiles.Any()) {
             return this.RenderJsonErrorCode(2, "Possible Existing Profiles", possibleMatchingProfiles.Select(x => new {
                 firstName = x.FirstName,
                 lastName = x.LastName,
                 emailAddress = x.EmailAddress,
             }).ToArray());
         }
     }
     var newProfile = DirectoryProfile.RegisterNewProfile(parameters);
     DocumentSession.Store(newProfile);
     return this.RenderJsonSuccessErrorCode();
 }