private static void CreatePersonWithProtectionProfile(Guid guid, AccountProtectionProfile accountProtectionProfile)
        {
            var rockContext   = new RockContext();
            var personService = new PersonService(rockContext);

            var person = personService.Get(guid);

            if (person != null)
            {
                new PersonAliasService(rockContext).DeleteRange(person.Aliases);
                new PersonSearchKeyService(rockContext).DeleteRange(person.GetPersonSearchKeys(rockContext).ToList());
                personService.Delete(person);
                rockContext.SaveChanges();
            }

            person = new Person()
            {
                RecordTypeValueId = DefinedValueCache.GetId(SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON.AsGuid()),
                FirstName         = "I Am A",
                LastName          = "Test Person",
                Guid = guid,
                AccountProtectionProfile = accountProtectionProfile
            };

            PersonService.SaveNewPerson(person, rockContext);
        }
Example #2
0
        private void SetPersonAccountProtectionProfile(String guid, AccountProtectionProfile profile)
        {
            var rockContext   = new RockContext();
            var personService = new PersonService(rockContext);

            var person = personService.Get(guid.AsGuid());

            person.AccountProtectionProfile = profile;

            rockContext.SaveChanges();
        }
Example #3
0
        /// <summary>
        /// Gets the account protection profile column HTML.
        /// </summary>
        /// <param name="accountProtectionProfile">The account protection profile.</param>
        /// <returns></returns>
        public string GetAccountProtectionProfileColumnHtml(AccountProtectionProfile accountProtectionProfile)
        {
            var cssMap = new Dictionary <AccountProtectionProfile, string>
            {
                { AccountProtectionProfile.Extreme, "danger" },
                { AccountProtectionProfile.High, "primary" },
                { AccountProtectionProfile.Medium, "warning" },
                { AccountProtectionProfile.Low, "success" }
            };

            var css = $"label label-{cssMap[accountProtectionProfile]}";


            return($"<span class='{css}'>{accountProtectionProfile.ConvertToString()}</span>");
        }