public override bool IsPersonInPersonTypeAdmin(Person person)
        {
            using (var transaction = new TransactionScope(_configuration))
            {
                var        ds = new PersonTypeDataStore(transaction);
                PersonType adminPersonType = ds.FindByName(BusiBlocksConstants.AdministratorsGroup);

                if (adminPersonType == null)
                {
                    return(false);
                }

                var pds = new PersonPersonTypeDataStore(transaction);
                IList <PersonPersonType> personTypes = pds.FindByPersonAndPersonType(person.Id, adminPersonType.Id);

                if (personTypes.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
 public override PersonType GetPersonTypeByName(string personTypeName)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var ptDS = new PersonTypeDataStore(transaction);
         return(ptDS.FindByName(personTypeName));
     }
 }
        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);
            }
        }
 /// <summary>
 /// Find all the person types.
 /// </summary>
 /// <returns></returns>
 public override IList <PersonType> GetAllPersonTypes(bool includeAdmin)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var ptDS = new PersonTypeDataStore(transaction);
         IList <PersonType> list = ptDS.FindAll();
         // Remove the System Administrators group from the list.
         if (!includeAdmin)
         {
             list.Remove(list.FirstOrDefault(x => x.Name.Equals(BusiBlocksConstants.AdministratorsGroup)));
         }
         return(list);
     }
 }
 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 bool PersonTypeExists(string personTypeName)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var ptDS = new PersonTypeDataStore(transaction);
         if (ptDS.FindByName(personTypeName) != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
        public override void DeletePersonType(string personTypeId)
        {
            if (PersonTypeHasRoles(personTypeId))
            {
                throw new ProviderException("Unable to delete. PersonType has Roles assigned to it");
            }

            using (var transaction = new TransactionScope(_configuration))
            {
                var        ptDS       = new PersonTypeDataStore(transaction);
                PersonType personType = ptDS.FindByKey(personTypeId);
                personType.Deleted = true;
                personType.Name   += DateTimeHelper.GetCurrentTimestamp();
                ptDS.Update(personType);
                transaction.Commit();
            }
        }
        public override void UpdatePersonType(PersonType personType)
        {
            //Check required for MSDN
            if (string.IsNullOrEmpty(personType.Name))
            {
                throw new ProviderException("PersonType name cannot be empty or null.");
            }
            if (personType.Name.IndexOf(',') > 0)
            {
                throw new ArgumentException("PersonType names cannot contain commas.");
            }

            using (var transaction = new TransactionScope(_configuration))
            {
                var ptDS = new PersonTypeDataStore(transaction);
                ptDS.Update(personType);
                transaction.Commit();
            }
        }