public override void DeletePerson(string personId)
        {
            // If person regions exist.
            if (IsPersonInPersonRegion(personId))
            {
                throw new SchemaIntegrityException("Unable to delete. Person exists in a Region");
            }

            // If person persontypes exist.
            if (IsPersonInPersonType(personId))
            {
                throw new SchemaIntegrityException("Unable to delete. Person exists in a PersonType");
            }

            // If person personsite exist.
            if (IsPersonInPersonSite(personId))
            {
                throw new SchemaIntegrityException("Unable to delete. Person exists at a Site");
            }

            using (var transaction = new TransactionScope(_configuration))
            {
                var    ptDS   = new PersonDataStore(transaction);
                Person person = ptDS.FindByKey(personId);
                User   user   = MembershipManager.GetUserByPerson(person);
                System.Web.Security.Membership.DeleteUser(user.Name);
                person.Deleted = true;
                ptDS.Update(person);
                transaction.Commit();
            }
        }
        public override void CreatePersonSite(string personId, string siteId, bool?isAdministrator, bool?isManager,
                                              bool?isAssigned, bool isDefault)
        {
            // Create a new record in the PersonSite table.
            using (var transaction = new TransactionScope(_configuration))
            {
                var psDS = new PersonSiteDataStore(transaction);
                var ps   = new PersonSite();
                var pDS  = new PersonDataStore(transaction);
                ps.Person = pDS.FindByKey(personId);
                var sDS = new SiteDataStore(transaction);
                ps.Site = sDS.FindByKey(siteId);
                if (isAdministrator != null)
                {
                    ps.IsAdministrator = (bool)isAdministrator;
                }
                if (isManager != null)
                {
                    ps.IsManager = (bool)isManager;
                }
                if (isAssigned != null)
                {
                    ps.IsAssigned = (bool)isAssigned;
                }
                ps.IsDefault = isDefault;
                psDS.Insert(ps);

                transaction.Commit();
            }
        }
 public override Person GetPersonById(string personId)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var pDS = new PersonDataStore(transaction);
         return(pDS.FindByKey(personId));
     }
 }
 public override IList <Person> GetPersonsByFirstName(string firstName)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var pDS = new PersonDataStore(transaction);
         return(pDS.FindAllByFirstName(firstName));
     }
 }
 public override IList <Person> GetAllPersons()
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var            ds        = new PersonDataStore(transaction);
         IList <string> sysAdmins = GetAdminIds();
         return(ds.FindAll().Where(x => !sysAdmins.Contains(x.Id)).ToList <Person>());
     }
 }
 public override void UpdatePerson(Person person)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var pDS = new PersonDataStore(transaction);
         pDS.Update(person);
         transaction.Commit();
     }
 }
 public override void CreatePersonPersonType(string personId, string personTypeId)
 {
     // Create a new record in the PersonPersonType table.
     using (var transaction = new TransactionScope(_configuration))
     {
         var pptDS = new PersonPersonTypeDataStore(transaction);
         var ppt   = new PersonPersonType();
         var pDS   = new PersonDataStore(transaction);
         ppt.Person = pDS.FindByKey(personId);
         var ptDS = new PersonTypeDataStore(transaction);
         ppt.PersonType = ptDS.FindByKey(personTypeId);
         pptDS.Insert(ppt);
         transaction.Commit();
     }
 }
        public override void CreatePerson(Person person, User user)
        {
            using (var transaction = new TransactionScope(_configuration))
            {
                var pDS = new PersonDataStore(transaction);

                user.Person = pDS.Insert(person);

                var uDS = new UserDataStore(transaction);

                uDS.Update(user);

                transaction.Commit();
            }
        }
        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();
            }
        }