/// <summary>
        /// Creates the test step program.
        /// There are 2 step statuses: 1 complete and 1 in-progress
        /// There are 4 step types:
        ///     1) Allow multiple with an auto-complete dataview
        ///     2) Allow multiple without an autocomplete dataview
        ///     3) No multiple with an auto-complete dataview
        ///     4) No multiple with no auto-complete dataview
        /// </summary>
        private static void CreateTestStepProgram()
        {
            var rockContext        = new RockContext();
            var stepProgramService = new StepProgramService(rockContext);

            var dataViewService = new DataViewService(rockContext);
            var dataView        = dataViewService.Queryable().FirstOrDefault(dv => dv.ForeignKey == ForeignKey);

            var stepProgram = new StepProgram
            {
                Name         = "Test",
                ForeignKey   = ForeignKey,
                StepStatuses = new List <StepStatus> {
                    new StepStatus
                    {
                        ForeignKey       = ForeignKey,
                        Name             = "Complete",
                        IsCompleteStatus = true
                    },
                    new StepStatus
                    {
                        ForeignKey       = ForeignKey,
                        Name             = "In-progress",
                        IsCompleteStatus = false
                    }
                },
                StepTypes = new List <StepType>
                {
                    new StepType
                    {
                        Name                 = "Test: AllowMultiple with DataView",
                        ForeignKey           = ForeignKey,
                        AllowMultiple        = true,
                        AutoCompleteDataView = dataView
                    },
                    new StepType
                    {
                        Name          = "Test: AllowMultiple without DataView",
                        ForeignKey    = ForeignKey,
                        AllowMultiple = true
                    },
                    new StepType
                    {
                        Name                 = "Test: No multiple with DataView",
                        ForeignKey           = ForeignKey,
                        AllowMultiple        = false,
                        AutoCompleteDataView = dataView
                    },
                    new StepType
                    {
                        Name          = "Test: No multiple and no dataview",
                        ForeignKey    = ForeignKey,
                        AllowMultiple = false
                    }
                }
            };

            stepProgramService.Add(stepProgram);
            rockContext.SaveChanges();
        }
Esempio n. 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();
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the test step program.
        /// There are 2 step statuses: 1 complete and 1 in-progress
        /// There are 4 step types.
        ///
        /// Jerry completed the program with two aliases
        /// Simon started the program
        /// Kathy completed the program 2x
        /// Barry started the program
        /// </summary>
        private static void CreateTestStepProgram()
        {
            var rockContext        = new RockContext();
            var stepProgramService = new StepProgramService(rockContext);
            var personService      = new PersonService(rockContext);

            var barryAliasId = personService.Get(BarryBopPersonGuidString.AsGuid()).PrimaryAliasId.Value;
            var kathyAliasId = personService.Get(KathyKolePersonGuidString.AsGuid()).PrimaryAliasId.Value;
            var simonAliasId = personService.Get(SimonSandsPersonGuidString.AsGuid()).PrimaryAliasId.Value;

            var jerryAliases  = personService.Get(JerryJenkinsPersonGuidString.AsGuid()).Aliases.ToList();
            var jerryAliasId1 = jerryAliases[0].Id;
            var jerryAliasId2 = jerryAliases[1].Id;

            var stepProgram = new StepProgram
            {
                Name         = "Test",
                ForeignKey   = ForeignKey,
                StepStatuses = new List <StepStatus> {
                    new StepStatus
                    {
                        ForeignKey       = ForeignKey,
                        Name             = "Complete",
                        IsCompleteStatus = true
                    },
                    new StepStatus
                    {
                        ForeignKey       = ForeignKey,
                        Name             = "In-progress",
                        IsCompleteStatus = false
                    }
                },
                StepTypes = new List <StepType>
                {
                    new StepType
                    {
                        Name          = "Test: Step Type 1",
                        ForeignKey    = ForeignKey,
                        AllowMultiple = true,
                        Steps         = new [] {
                            new Step {
                                PersonAliasId     = jerryAliasId2,
                                CompletedDateTime = new DateTime(2019, 2, 1),
                                StartDateTime     = new DateTime(2019, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = simonAliasId,
                                CompletedDateTime = new DateTime(2019, 2, 1),
                                StartDateTime     = new DateTime(2019, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = barryAliasId,
                                CompletedDateTime = new DateTime(2019, 2, 1),
                                StartDateTime     = new DateTime(2019, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = barryAliasId,
                                CompletedDateTime = new DateTime(2019, 2, 1),
                                StartDateTime     = new DateTime(2019, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = kathyAliasId,
                                CompletedDateTime = new DateTime(2020, 2, 1),
                                StartDateTime     = new DateTime(2020, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = kathyAliasId,
                                CompletedDateTime = new DateTime(2019, 2, 1),
                                StartDateTime     = new DateTime(2019, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                        }
                    },
                    new StepType
                    {
                        Name          = "Test: Step Type 2",
                        ForeignKey    = ForeignKey,
                        AllowMultiple = true,
                        Steps         = new [] {
                            new Step {
                                PersonAliasId     = jerryAliasId1,
                                CompletedDateTime = new DateTime(2020, 3, 1),
                                StartDateTime     = new DateTime(2020, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = kathyAliasId,
                                CompletedDateTime = new DateTime(2020, 2, 1),
                                StartDateTime     = new DateTime(2020, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = kathyAliasId,
                                CompletedDateTime = new DateTime(2019, 2, 1),
                                StartDateTime     = new DateTime(2019, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                        }
                    },
                    new StepType
                    {
                        Name          = "Test: Step Type 3",
                        ForeignKey    = ForeignKey,
                        AllowMultiple = false,
                        Steps         = new [] {
                            new Step {
                                PersonAliasId     = jerryAliasId1,
                                CompletedDateTime = new DateTime(2020, 2, 1),
                                StartDateTime     = new DateTime(2020, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = kathyAliasId,
                                CompletedDateTime = new DateTime(2020, 2, 1),
                                StartDateTime     = new DateTime(2020, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = kathyAliasId,
                                CompletedDateTime = new DateTime(2019, 2, 1),
                                StartDateTime     = new DateTime(2019, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                        }
                    },
                    new StepType
                    {
                        Name          = "Test: Step Type 4",
                        ForeignKey    = ForeignKey,
                        AllowMultiple = false,
                        Steps         = new [] {
                            new Step {
                                PersonAliasId     = jerryAliasId1,
                                CompletedDateTime = new DateTime(2020, 2, 1),
                                StartDateTime     = new DateTime(2020, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = kathyAliasId,
                                CompletedDateTime = new DateTime(2020, 2, 1),
                                StartDateTime     = new DateTime(2020, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                            new Step {
                                PersonAliasId     = kathyAliasId,
                                CompletedDateTime = new DateTime(2019, 4, 1),
                                StartDateTime     = new DateTime(2019, 1, 1),
                                ForeignKey        = ForeignKey
                            },
                        }
                    }
                }
            };

            stepProgramService.Add(stepProgram);
            rockContext.SaveChanges();
        }