/// <summary>
        /// Modifies the PersonRegion record.
        /// If one of personId or regionId are null, then it is implied that all records for the not null item are to be updated.
        /// If one of isAdministrator or isManager are null, then it is implied that the not null item is to be updated.
        /// If a record is updated so that both isAdministrator and isManager are false, then that record is deleted.
        /// </summary>
        /// <param name="personId"></param>
        /// <param name="regionId"></param>
        /// <param name="isAdministrator"></param>
        /// <param name="isManager"></param>
        public override void UpdatePersonRegion(string personId, bool?isAdministrator, bool?isManager)
        {
            if (isAdministrator == null && isManager == null)
            {
                throw new ArgumentNullException("isAdministrator", "Both isAdministrator and isManager cannot be null");
            }

            using (var transaction = new TransactionScope(_configuration))
            {
                var prDS = new PersonRegionDataStore(transaction);
                IList <PersonRegion> prs = prDS.FindRegionsByPerson(personId);

                foreach (PersonRegion pr in prs)
                {
                    // A value of null for isAdministrator and isManager is equivalent to false.
                    if (!isAdministrator.HasValue)
                    {
                        // Only modify the manager values
                        pr.IsManager = (bool)isManager;

                        if (!pr.IsAdministrator && !pr.IsManager)
                        {
                            prDS.Delete(pr.Id);
                        }
                        else
                        {
                            prDS.Update(pr);
                        }
                    }
                    else if (!isManager.HasValue)
                    {
                        // Only modify the manager values
                        pr.IsAdministrator = (bool)isAdministrator;

                        if (!pr.IsAdministrator && !pr.IsManager)
                        {
                            prDS.Delete(pr.Id);
                        }
                        else
                        {
                            prDS.Update(pr);
                        }
                    }
                }
                transaction.Commit();
            }
        }
 public override void UpdatePersonRegion(PersonRegion personRegion)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var prDS = new PersonRegionDataStore(transaction);
         prDS.Update(personRegion);
         transaction.Commit();
     }
 }
        public override void DeletePersonFromRegion(string personId, string regionId)
        {
            using (var transaction = new TransactionScope(_configuration))
            {
                var prDS = new PersonRegionDataStore(transaction);
                IList <PersonRegion> prs = prDS.FindByPersonAndRegion(personId, regionId);

                foreach (PersonRegion item in prs)
                {
                    item.Deleted = true;
                    prDS.Update(item);
                }

                transaction.Commit();
            }
        }