public override bool IsUserInPersonType(string userName, string personTypeId)
        {
            using (var transaction = new TransactionScope(_configuration))
            {
                var pptDS = new PersonPersonTypeDataStore(transaction);
                IList <PersonPersonType> peoples = pptDS.FindPersonByPersonType(personTypeId);

                // Find the person who corresponds to username.
                var  uDS  = new UserDataStore(transaction);
                User user = uDS.FindByName(_applicationName, userName);

                // If there is no matching person, then do not continue.
                if (user.Person == null)
                {
                    throw new PersonNotFoundException(user.Name);
                }

                IEnumerable <PersonPersonType> q = from x in peoples where x.Person.Id.Equals(user.Person.Id) select x;

                if (q.Count() > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        public override IList <Person> GetAllPersonsByPersonType(PersonType personType)
        {
            IList <Person> personList = new List <Person>();

            using (var transaction = new TransactionScope(_configuration))
            {
                // Find all the persons in the person person type table.
                var ds = new PersonPersonTypeDataStore(transaction);
                IList <PersonPersonType> personPersonTypes = ds.FindPersonByPersonType(personType.Id);
                personList = personPersonTypes.Select(x => x.Person).ToList <Person>();
            }
            return(personList);
        }
        private IList <string> GetAdminIds()
        {
            // First get all the system admin ids.
            using (var transaction = new TransactionScope(_configuration))
            {
                var        ds2 = new PersonTypeDataStore(transaction);
                PersonType sysAdminPersonType = ds2.FindByName(BusiBlocksConstants.AdministratorsGroup);

                var ds1 = new PersonPersonTypeDataStore(transaction);
                IList <PersonPersonType> sysAdmins   = ds1.FindPersonByPersonType(sysAdminPersonType.Id);
                IList <string>           sysAdminIds = sysAdmins.Select(x => x.Person.Id).ToList <string>();
                return(sysAdminIds);
            }
        }
        public override bool IsPersonInPersonType(Person person, PersonType personType)
        {
            using (var transaction = new TransactionScope(_configuration))
            {
                var pptDS = new PersonPersonTypeDataStore(transaction);
                IList <PersonPersonType> peoples = pptDS.FindPersonByPersonType(personType.Id);

                IEnumerable <PersonPersonType> q = from x in peoples where x.Person.Id.Equals(person.Id) select x;

                if (q.Count() > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }