/// <summary>
        /// Creates the person alias data.
        /// </summary>
        private static void CreatePersonAliasData()
        {
            var tedDeckerGuid = TestGuids.TestPeople.TedDecker.AsGuid();

            var personAliasService = new PersonAliasService(_rockContext);
            var personService      = new PersonService(_rockContext);
            var tedDecker          = personService.Get(tedDeckerGuid);
            var aliasPersonId      = personService.Queryable().Max(p => p.Id) + 1;

            personAliasService.DeleteRange(personAliasService.Queryable().Where(pa => pa.AliasPersonId >= aliasPersonId));
            _rockContext.SaveChanges();

            for (var i = 0; i < NUMBER_OF_ALIASES; i++)
            {
                personAliasService.Add(new PersonAlias {
                    Person = tedDecker, AliasPersonGuid = Guid.NewGuid(), AliasPersonId = aliasPersonId + i, ForeignKey = KEY
                });
            }

            _rockContext.SaveChanges();

            var personAlias = personAliasService.Queryable().Where(pa => pa.Person.Guid == tedDeckerGuid && pa.ForeignKey == KEY).Take(NUMBER_OF_ALIASES).Select(p => p.Id).ToList();

            _personAliasIds = personAlias;
        }
示例#2
0
        /// <summary>
        /// Creates the test people.
        /// 3 people are included in a dataview because of their middle name.
        /// 1 person (part of the 3 in the dataview) has multiple person aliases.
        /// </summary>
        private static void CreateTestPeople()
        {
            var rockContext        = new RockContext();
            var personService      = new PersonService(rockContext);
            var personAliasService = new PersonAliasService(rockContext);

            // Create 4 people. 3 are part of a dataview because of their middle name
            var personSimonSands = new Person
            {
                FirstName  = "Simon",
                LastName   = "Sands",
                Guid       = SimonSandsPersonGuidString.AsGuid(),
                ForeignKey = ForeignKey
            };

            var personBarryBop = new Person
            {
                FirstName  = "Barry",
                LastName   = "Bop",
                Guid       = BarryBopPersonGuidString.AsGuid(),
                ForeignKey = ForeignKey
            };

            // Not in the dataview
            var personKathyKole = new Person
            {
                FirstName  = "Kathy",
                LastName   = "Kole",
                Guid       = KathyKolePersonGuidString.AsGuid(),
                ForeignKey = ForeignKey
            };

            var personJerryJenkins = new Person
            {
                FirstName  = "Jerry",
                LastName   = "Jenkins",
                Guid       = JerryJenkinsPersonGuidString.AsGuid(),
                ForeignKey = ForeignKey
            };

            personService.Add(personJerryJenkins);
            personService.Add(personSimonSands);
            personService.Add(personKathyKole);
            personService.Add(personBarryBop);
            rockContext.SaveChanges();

            // Add multiple aliases for Jerry
            personAliasService.Add(new PersonAlias
            {
                ForeignKey    = ForeignKey,
                Person        = personJerryJenkins,
                AliasPersonId = 5000000
            });

            personAliasService.Add(new PersonAlias
            {
                ForeignKey    = ForeignKey,
                Person        = personJerryJenkins,
                AliasPersonId = 5000001
            });

            personAliasService.Add(new PersonAlias
            {
                ForeignKey    = ForeignKey,
                Person        = personJerryJenkins,
                AliasPersonId = 5000002
            });

            personAliasService.Add(new PersonAlias
            {
                ForeignKey    = ForeignKey,
                Person        = personJerryJenkins,
                AliasPersonId = 5000003
            });

            rockContext.SaveChanges();
        }