Esempio n. 1
0
        /// <summary>
        /// Delete the current entity.
        /// </summary>
        private void DeleteCurrentEntity()
        {
            var targetEntity = this.GetTargetEntity();

            if (targetEntity == null)
            {
                return;
            }

            if (!targetEntity.IsAuthorized(Authorization.ADMINISTRATE, this.CurrentPerson))
            {
                mdDeleteWarning.Show("You are not authorized to delete this item.", ModalAlertType.Information);
                return;
            }

            var rockContext = this.GetDataContext();

            var assessmentTypeService = new AssessmentTypeService(rockContext);

            string errorMessage;

            if (!assessmentTypeService.CanDelete(targetEntity, out errorMessage))
            {
                mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                return;
            }

            assessmentTypeService.Delete(targetEntity);

            rockContext.SaveChanges();

            NavigateToParentPage();
        }
Esempio n. 2
0
        /// <summary>
        /// Delete the entities corresponding to list items that are deleted.
        /// </summary>
        /// <param name="dataContext"></param>
        /// <param name="entityId"></param>
        /// <returns></returns>
        private bool OnDeleteEntity(RockContext dataContext, int entityId)
        {
            var assessmentTypeService = new AssessmentTypeService(dataContext);

            var assessmentType = assessmentTypeService.Get(entityId);

            if (assessmentType == null)
            {
                ShowAlert("This item could not be found.");
                return(false);
            }

            string errorMessage;

            if (!assessmentTypeService.CanDelete(assessmentType, out errorMessage))
            {
                ShowAlert(errorMessage, ModalAlertType.Warning);
                return(false);
            }

            assessmentTypeService.Delete(assessmentType);

            return(true);
        }