public override IList <Person> GetPersonsByRegionName(string regionName, bool recursive)
        {
            IList <Region> regions = SiteManager.GetAllRegionsByName(regionName);

            using (var transaction = new TransactionScope(_configuration))
            {
                IList <Person> persons = new List <Person>();
                foreach (Region region in regions)
                {
                    IList <Site> sites = SiteManager.GetAllSitesByRegion(region, recursive);

                    // Find all persons at these sites.
                    var psDS = new PersonSiteDataStore(transaction);
                    foreach (Site site in sites)
                    {
                        IList <PersonSite> personAtSites = psDS.FindPersonsBySite(site.Id, false);
                        if (persons == null)
                        {
                            IEnumerable <Person> ppl =
                                from x in personAtSites
                                select x.Person;

                            persons = ppl.ToList <Person>();
                        }
                        else
                        {
                            foreach (PersonSite personSite in personAtSites)
                            {
                                persons.Add(personSite.Person);
                            }
                        }
                    }

                    if (recursive)
                    {
                        // Find all child regions.
                        var            rDS          = new RegionDataStore(transaction);
                        IList <Region> childRegions = rDS.FindByParentRegion(region.Id);
                        foreach (Region subRegion in childRegions)
                        {
                            IList <Person> subPersons = GetPersonsByRegionName(subRegion.Name, recursive);
                            foreach (Person subPerson in subPersons)
                            {
                                persons.Add(subPerson);
                            }
                        }
                    }
                }
                return(persons);
            }
        }
        public override void CreatePersonRegion(string personId, string regionId, bool?isAdministrator, bool?isManager)
        {
            using (var transaction = new TransactionScope(_configuration))
            {
                var psDS = new PersonRegionDataStore(transaction);
                var pr   = new PersonRegion();
                var pDS  = new PersonDataStore(transaction);
                pr.Person = pDS.FindByKey(personId);
                var rDS = new RegionDataStore(transaction);
                pr.Region = rDS.FindByKey(regionId);
                if (isAdministrator != null)
                {
                    pr.IsAdministrator = (bool)isAdministrator;
                }
                if (isManager != null)
                {
                    pr.IsManager = (bool)isManager;
                }
                psDS.Insert(pr);

                transaction.Commit();
            }
        }