コード例 #1
0
        private static AchievementType CreateAchievementType(
            string name,
            string accountGuid,
            bool includeChildAccounts = false,
            bool isActive             = true,
            int maxAllowed            = 1,
            bool allowOver            = false,
            int numberToAccumulate    = 1)
        {
            var achievement = new AchievementType
            {
                Name     = name,
                IsActive = isActive,
                ComponentEntityTypeId     = EntityTypeCache.GetId(ComponentEntityTypeName) ?? 0,
                MaxAccomplishmentsAllowed = maxAllowed,
                AllowOverAchievement      = allowOver,
                ComponentConfigJson       = "{ \"GivingToAccountAchievement\": \"null\" }",
                ForeignKey = KEY
            };

            _achievementTypeService.Add(achievement);
            _rockContext.SaveChanges(true);

            achievement.LoadAttributes();
            achievement.SetAttributeValue(Rock.Achievement.Component.GivingToAccountAchievement.AttributeKey.IncludeChildFinancialAccounts, includeChildAccounts.ToString());
            achievement.SetAttributeValue(Rock.Achievement.Component.GivingToAccountAchievement.AttributeKey.FinancialAccount, accountGuid);
            achievement.SetAttributeValue(Rock.Achievement.Component.GivingToAccountAchievement.AttributeKey.StartDateTime, _startDate.ToISO8601DateString());
            achievement.SetAttributeValue(Rock.Achievement.Component.GivingToAccountAchievement.AttributeKey.EndDateTime, _endDate.ToISO8601DateString());
            achievement.SetAttributeValue(Rock.Achievement.Component.GivingToAccountAchievement.AttributeKey.NumberToAccumulate, numberToAccumulate.ToString());
            achievement.SaveAttributeValues();

            return(achievement);
        }
コード例 #2
0
        /// <summary>
        /// Creates the achievement type data.
        /// </summary>
        private static void CreateAchievementTypeData()
        {
            var achievementType = new AchievementType
            {
                Name     = "Test Achievement",
                IsActive = true,
                ComponentEntityTypeId     = EntityTypeCache.GetId(ComponentEntityTypeName) ?? 0,
                MaxAccomplishmentsAllowed = 1,
                AllowOverAchievement      = false,
                ComponentConfigJson       = "{ \"InteractionChannelComponent\": \"" +
                                            _interactionComponent.InteractionChannel.Guid + "|" +
                                            _interactionComponent.Guid + "\" }"
            };

            _achievementTypeService.Add(achievementType);
            _rockContext.SaveChanges(true);

            achievementType.LoadAttributes();
            achievementType.SetAttributeValue(Rock.Achievement.Component.InteractionSourcedAccumulativeAchievement.AttributeKey.NumberToAccumulate, NUMBER_TO_ACHIEVE.ToString());
            achievementType.SaveAttributeValues();

            _achievementTypeId = achievementType.Id;
        }