예제 #1
0
        /// <summary>
        /// Handles the Delete event of the gStepProgram control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        protected void gStepProgram_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();

            var stepProgramService = new StepProgramService(rockContext);

            var stepProgram = stepProgramService.Get(e.RowKeyId);

            if (stepProgram == null)
            {
                mdGridWarning.Show("This item could not be found.", ModalAlertType.Information);
                return;
            }

            string errorMessage;

            if (!stepProgramService.CanDelete(stepProgram, out errorMessage))
            {
                mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                return;
            }

            stepProgramService.Delete(stepProgram);

            rockContext.SaveChanges();

            BindGrid();
        }
예제 #2
0
        private StepProgram GetStepProgram(RockContext dataContext, int stepProgramId)
        {
            var programService = new StepProgramService(dataContext);

            var stepProgram = programService.Get(stepProgramId);

            return(stepProgram);
        }
예제 #3
0
        /// <summary>
        /// Populates the selection lists for Step Type and Step Status.
        /// </summary>
        /// <param name="filterField">The filter field.</param>
        private void PopulateStepProgramRelatedSelectionLists(FilterField filterField)
        {
            var dataContext = new RockContext();

            var programService = new StepProgramService(dataContext);

            SingleEntityPicker <StepProgram> stepProgramSingleEntityPicker = filterField.ControlsOfTypeRecursive <SingleEntityPicker <StepProgram> >().FirstOrDefault(c => c.HasCssClass("js-step-program-picker"));
            RockCheckBoxList cblStepType    = filterField.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(c => c.HasCssClass("js-step-type"));
            RockCheckBoxList _cblStepStatus = filterField.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(c => c.HasCssClass("js-step-status"));

            int?stepProgramId = stepProgramSingleEntityPicker.SelectedId;

            StepProgram stepProgram = null;

            if (stepProgramId != null)
            {
                stepProgram = programService.Get(stepProgramId.Value);
            }

            if (stepProgram != null)
            {
                // Step Type list
                cblStepType.Items.Clear();

                var stepTypeService = new StepTypeService(dataContext);

                var stepTypes = stepTypeService.Queryable().Where(x => x.StepProgramId == stepProgramId);

                foreach (var item in stepTypes)
                {
                    cblStepType.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                cblStepType.Visible = cblStepType.Items.Count > 0;

                // Step Status list
                _cblStepStatus.Items.Clear();

                var stepStatusService = new StepStatusService(dataContext);

                var stepStatuses = stepStatusService.Queryable().Where(x => x.StepProgramId == stepProgramId);

                foreach (var item in stepStatuses)
                {
                    _cblStepStatus.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                _cblStepStatus.Visible = _cblStepStatus.Items.Count > 0;
            }
            else
            {
                cblStepType.Visible    = false;
                _cblStepStatus.Visible = false;
            }
        }
예제 #4
0
        private StepProgram GetStepProgram(RockContext dataContext, Guid?stepProgramGuid)
        {
            if (stepProgramGuid == null)
            {
                return(null);
            }

            var programService = new StepProgramService(dataContext);

            var stepProgram = programService.Get(stepProgramGuid.Value);

            return(stepProgram);
        }
예제 #5
0
        /// <summary>
        /// Gets the specified <see cref="StepProgram"/> by Id.
        /// </summary>
        /// <param name="stepProgramGuid">The identifier of the <see cref="StepProgram"/>.</param>
        /// <returns>A <see cref="StepProgram"/> or null.</returns>
        private StepProgram GetStepProgram(Guid?stepProgramGuid)
        {
            if (!stepProgramGuid.HasValue || stepProgramGuid.Value == Guid.Empty)
            {
                return(null);
            }

            using (var rockContext = new RockContext())
            {
                var stepTypeService = new StepProgramService(rockContext);
                return(stepTypeService.Get(stepProgramGuid.Value));
            }
        }
예제 #6
0
        /// <summary>
        /// Populates the selection lists for Step Type and Step Status.
        /// </summary>
        /// <param name="stepProgramId">The Step Program identifier.</param>
        private void PopulateStepProgramRelatedSelectionLists(int?stepProgramId)
        {
            var dataContext = new RockContext();

            var programService = new StepProgramService(dataContext);

            StepProgram stepProgram = null;

            if (stepProgramId != null)
            {
                stepProgram = programService.Get(stepProgramId.Value);
            }

            if (stepProgram != null)
            {
                // Step Type list
                _cblStepType.Items.Clear();

                var stepTypeService = new StepTypeService(dataContext);

                var stepTypes = stepTypeService.Queryable().Where(x => x.StepProgramId == stepProgramId);

                foreach (var item in stepTypes)
                {
                    _cblStepType.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                _cblStepType.Visible = _cblStepType.Items.Count > 0;

                // Step Status list
                _cblStepStatus.Items.Clear();

                var stepStatusService = new StepStatusService(dataContext);

                var stepStatuses = stepStatusService.Queryable().Where(x => x.StepProgramId == stepProgramId);

                foreach (var item in stepStatuses)
                {
                    _cblStepStatus.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                _cblStepStatus.Visible = _cblStepStatus.Items.Count > 0;
            }
            else
            {
                _cblStepType.Visible   = false;
                _cblStepStatus.Visible = false;
            }
        }