Exemplo n.º 1
0
        /// <summary>
        /// Delete the test data
        /// </summary>
        private static void DeleteTestData()
        {
            using (var rockContext = new RockContext())
            {
                var stepService = new StepService(rockContext);
                var stepQuery   = stepService.Queryable().Where(s => s.ForeignKey == ForeignKey);
                stepService.DeleteRange(stepQuery);
                rockContext.SaveChanges();
            }

            using (var rockContext = new RockContext())
            {
                var stepProgramService = new StepProgramService(rockContext);
                var stepProgramQuery   = stepProgramService.Queryable().Where(sp => sp.ForeignKey == ForeignKey);
                stepProgramService.DeleteRange(stepProgramQuery);
                rockContext.SaveChanges();
            }

            using (var rockContext = new RockContext())
            {
                var personSearchKeyService = new PersonSearchKeyService(rockContext);
                var personSearchKeyQuery   = personSearchKeyService.Queryable()
                                             .Where(psk =>
                                                    psk.PersonAlias.Person.ForeignKey == ForeignKey ||
                                                    PersonGuids.Contains(psk.PersonAlias.Person.Guid));
                personSearchKeyService.DeleteRange(personSearchKeyQuery);
                rockContext.SaveChanges();
            }

            using (var rockContext = new RockContext())
            {
                var personAliasService = new PersonAliasService(rockContext);
                var personAliasQuery   = personAliasService.Queryable()
                                         .Where(pa =>
                                                pa.Person.ForeignKey == ForeignKey ||
                                                PersonGuids.Contains(pa.Person.Guid));
                personAliasService.DeleteRange(personAliasQuery);
                rockContext.SaveChanges();
            }

            using (var rockContext = new RockContext())
            {
                var personService = new PersonService(rockContext);
                var personQuery   = personService.Queryable()
                                    .Where(p =>
                                           p.ForeignKey == ForeignKey ||
                                           PersonGuids.Contains(p.Guid));
                personService.DeleteRange(personQuery);
                rockContext.SaveChanges();
            }
        }
        /// <summary>
        /// Delete the test data
        /// </summary>
        private static void DeleteTestData()
        {
            var rockContext = new RockContext();

            var stepProgramService = new StepProgramService(rockContext);
            var stepProgramQuery   = stepProgramService.Queryable().Where(sp => sp.ForeignKey == ForeignKey);

            stepProgramService.DeleteRange(stepProgramQuery);
            rockContext.SaveChanges();

            var dataViewFilterService = new DataViewFilterService(rockContext);
            var dvfQuery = dataViewFilterService.Queryable().Where(dvf => dvf.DataView.ForeignKey == ForeignKey || dvf.ForeignKey == ForeignKey);

            dataViewFilterService.DeleteRange(dvfQuery);
            rockContext.SaveChanges();

            var dataViewService = new DataViewService(rockContext);
            var dvQuery         = dataViewService.Queryable().Where(dv => dv.ForeignKey == ForeignKey);

            dataViewService.DeleteRange(dvQuery);
            rockContext.SaveChanges();

            var personSearchKeyService = new PersonSearchKeyService(rockContext);
            var personSearchKeyQuery   = personSearchKeyService.Queryable().Where(psk => psk.PersonAlias.Person.ForeignKey == ForeignKey);

            personSearchKeyService.DeleteRange(personSearchKeyQuery);

            var personAliasService = new PersonAliasService(rockContext);
            var personAliasQuery   = personAliasService.Queryable().Where(pa => pa.Person.ForeignKey == ForeignKey || pa.ForeignKey == ForeignKey);

            personAliasService.DeleteRange(personAliasQuery);
            rockContext.SaveChanges();

            var personService = new PersonService(rockContext);
            var personQuery   = personService.Queryable().Where(p => p.ForeignKey == ForeignKey);

            personService.DeleteRange(personQuery);
            rockContext.SaveChanges();
        }