Пример #1
0
        /// <summary>
        /// Get a list of the prerequisites for the given step type id
        /// </summary>
        /// <param name="stepTypeId"></param>
        /// <returns></returns>
        private List <StepType> GetPrerequisiteStepTypes(int stepTypeId)
        {
            var rockContext = GetRockContext();
            var service     = new StepTypePrerequisiteService(rockContext);

            return(service.Queryable()
                   .AsNoTracking()
                   .Include(stp => stp.PrerequisiteStepType)
                   .Where(stp => stp.StepTypeId == stepTypeId && stp.PrerequisiteStepType.IsActive)
                   .Select(stp => stp.PrerequisiteStepType)
                   .ToList());
        }
Пример #2
0
        public void AddTestDataStepPrograms()
        {
            var dataContext = new RockContext();

            // Add Step Categories
            var categoryService = new CategoryService(dataContext);

            var categoryId = EntityTypeCache.Get(typeof(Rock.Model.StepProgram)).Id;

            var adultCategory = CreateCategory("Adult", Constants.CategoryAdultsGuid, 1, categoryId);
            var childCategory = CreateCategory("Youth", Constants.CategoryYouthGuid, 2, categoryId);

            categoryService.Add(adultCategory);
            categoryService.Add(childCategory);

            dataContext.SaveChanges();

            var stepProgramService = new StepProgramService(dataContext);

            // Add Step Program "Sacraments"
            var programSacraments = CreateStepProgram(Constants.ProgramSacramentsGuid, Constants.CategoryAdultsGuid, "Sacraments", "The sacraments represent significant milestones in the Christian faith journey.", "fa fa-bible", 1);

            stepProgramService.Add(programSacraments);

            AddStepStatusToStepProgram(programSacraments, Constants.StatusSacramentsSuccessGuid, "Success", true, Constants.ColorCodeGreen, 1);
            AddStepStatusToStepProgram(programSacraments, Constants.StatusSacramentsPendingGuid, "Pending", false, Constants.ColorCodeBlue, 2);
            AddStepStatusToStepProgram(programSacraments, Constants.StatusSacramentsIncompleteGuid, "Incomplete", false, Constants.ColorCodeRed, 3);

            AddStepTypeToStepProgram(programSacraments, Constants.StepTypeBaptismGuid, "Baptism", "fa fa-tint", 1);

            var confirmationStepType = AddStepTypeToStepProgram(programSacraments, Constants.StepTypeConfirmationGuid, "Confirmation", "fa fa-bible", 2);

            AddStepTypeToStepProgram(programSacraments, Constants.StepTypeEucharistGuid, "Eucharist", "fa fa-cookie", 3);
            AddStepTypeToStepProgram(programSacraments, Constants.StepTypeConfessionGuid, "Confession", "fa fa-praying-hands", 4);
            AddStepTypeToStepProgram(programSacraments, Constants.StepTypeAnnointingGuid, "Annointing of the Sick", "fa fa-comment-medical", 5);
            AddStepTypeToStepProgram(programSacraments, Constants.StepTypeMarriageGuid, "Marriage", "fa fa-ring", 6);

            var holyOrdersStepType = AddStepTypeToStepProgram(programSacraments, Constants.StepTypeHolyOrdersGuid, "Holy Orders", "fa fa-cross", 7);

            dataContext.SaveChanges();

            // Add prerequisites
            var prerequisiteService = new StepTypePrerequisiteService(dataContext);

            var stepPrerequisite = new StepTypePrerequisite();

            stepPrerequisite.Guid                   = Constants.PrerequisiteHolyOrdersGuid;
            stepPrerequisite.StepTypeId             = holyOrdersStepType.Id;
            stepPrerequisite.PrerequisiteStepTypeId = confirmationStepType.Id;

            prerequisiteService.Add(stepPrerequisite);

            dataContext.SaveChanges();

            // Add Step Program "Alpha"
            var programAlpha = CreateStepProgram(Constants.ProgramAlphaGuid, Constants.CategoryAdultsGuid, "Alpha", "Alpha is a series of interactive sessions that freely explore the basics of the Christian faith.", "fa fa-question", 2);

            stepProgramService.Add(programAlpha);

            AddStepStatusToStepProgram(programAlpha, Constants.StatusAlphaCompletedGuid, "Completed", true, Constants.ColorCodeGreen, 1);
            AddStepStatusToStepProgram(programAlpha, Constants.StatusAlphaStartedGuid, "Started", false, Constants.ColorCodeBlue, 2);

            AddStepTypeToStepProgram(programAlpha, Constants.StepTypeAttenderGuid, "Attender", "fa fa-user", 1, hasEndDate: true);
            AddStepTypeToStepProgram(programAlpha, Constants.StepTypeVolunteerGuid, "Volunteer", "fa fa-hand-paper", 2, hasEndDate: true);
            AddStepTypeToStepProgram(programAlpha, Constants.StepTypeLeaderGuid, "Leader", "fa fa-user-graduate", 3, hasEndDate: true);

            dataContext.SaveChanges();
        }