示例#1
0
        /// <summary>
        /// Handles the Delete event of the gGroupType 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 gGroupType_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                GroupTypeService groupTypeService = new GroupTypeService();
                GroupType groupType = groupTypeService.Get(e.RowKeyId);

                if (groupType != null)
                {
                    int groupTypeId = groupType.Id;

                    if (!groupType.IsAuthorized("Administrate", CurrentPerson))
                    {
                        mdGridWarning.Show("Sorry, you're not authorized to delete this group type.", ModalAlertType.Alert);
                        return;
                    }

                    string errorMessage;
                    if (!groupTypeService.CanDelete(groupType, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Alert);
                        return;
                    }

                    groupTypeService.Delete(groupType, CurrentPersonId);
                    groupTypeService.Save(groupType, CurrentPersonId);

                    GroupTypeCache.Flush(groupTypeId);
                }
            });

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gGroupType 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 gGroupType_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();
            GroupTypeService groupTypeService = new GroupTypeService(rockContext);
            GroupType        groupType        = groupTypeService.Get(e.RowKeyId);

            if (groupType != null)
            {
                int groupTypeId = groupType.Id;

                if (!groupType.IsAuthorized("Administrate", CurrentPerson))
                {
                    mdGridWarning.Show("Sorry, you're not authorized to delete this group type.", ModalAlertType.Alert);
                    return;
                }

                string errorMessage;
                if (!groupTypeService.CanDelete(groupType, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Alert);
                    return;
                }

                groupType.ParentGroupTypes.Clear();
                groupType.ChildGroupTypes.Clear();

                groupTypeService.Delete(groupType);
                rockContext.SaveChanges();

                GroupTypeCache.Flush(groupTypeId);
            }

            BindGrid();
        }
示例#3
0
        /// <summary>
        /// Handles the Click event of the btnDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            var rockContext = new RockContext();
            GroupTypeService groupTypeService = new GroupTypeService(rockContext);
            GroupType        groupType        = groupTypeService.Get(hfGroupTypeId.Value.AsInteger());

            if (groupType != null)
            {
                string errorMessage;
                if (!groupTypeService.CanDelete(groupType, out errorMessage))
                {
                    mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                int groupTypeId = groupType.Id;

                groupType.ParentGroupTypes.Clear();
                groupType.ChildGroupTypes.Clear();

                groupTypeService.Delete(groupType);
                rockContext.SaveChanges();

                Rock.CheckIn.KioskDevice.Clear();
            }

            var pageRef = new PageReference(CurrentPageReference.PageId, CurrentPageReference.RouteId);

            NavigateToPage(pageRef);
        }
示例#4
0
        /// <summary>
        /// Handles the Delete button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                if (checkinArea.Visible)
                {
                    GroupTypeService groupTypeService = new GroupTypeService(rockContext);
                    GroupType        groupType        = groupTypeService.Get(checkinArea.GroupTypeGuid);
                    if (groupType != null)
                    {
                        if (IsInheritedGroupTypeRecursive(groupType, groupTypeService))
                        {
                            nbDeleteWarning.Text    = "WARNING - Cannot delete. This group type or one of its child group types is assigned as an inherited group type.";
                            nbDeleteWarning.Visible = true;
                            return;
                        }

                        string errorMessage;
                        if (!groupTypeService.CanDelete(groupType, out errorMessage))
                        {
                            nbDeleteWarning.Text    = "WARNING - Cannot Delete: " + errorMessage;
                            nbDeleteWarning.Visible = true;
                            return;
                        }

                        int id = groupType.Id;

                        groupType.ParentGroupTypes.Clear();
                        groupType.ChildGroupTypes.Clear();
                        groupTypeService.Delete(groupType);
                        rockContext.SaveChanges();
                        Rock.CheckIn.KioskDevice.Clear();
                    }
                    SelectArea(null);
                }

                if (checkinGroup.Visible)
                {
                    GroupService groupService = new GroupService(rockContext);
                    Group        group        = groupService.Get(checkinGroup.GroupGuid);
                    if (group != null)
                    {
                        string errorMessage;
                        if (!groupService.CanDelete(group, out errorMessage))
                        {
                            nbDeleteWarning.Text    = "WARNING - Cannot Delete: " + errorMessage;
                            nbDeleteWarning.Visible = true;
                            return;
                        }


                        groupService.Delete(group);   //Delete if group isn't active
                        rockContext.SaveChanges();
                        Rock.CheckIn.KioskDevice.Clear();
                        SelectGroup(null);
                    }
                }
            }
            BuildRows();
        }
示例#5
0
        /// <summary>
        /// Handles the Delete event of the gGroupType 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 gGroupType_Delete(object sender, RowEventArgs e)
        {
            GroupTypeService groupTypeService = new GroupTypeService();
            GroupType        groupType        = groupTypeService.Get((int)e.RowKeyValue);

            string errorMessage;

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

            groupTypeService.Delete(groupType, CurrentPersonId);
            groupTypeService.Save(groupType, CurrentPersonId);

            BindGrid();
        }
        private void CheckinAreaRow_DeleteAreaClick(object sender, EventArgs e)
        {
            var row = sender as CheckinAreaRow;

            using (var rockContext = new RockContext())
            {
                var groupTypeService = new GroupTypeService(rockContext);
                var groupType        = groupTypeService.Get(row.GroupTypeGuid);
                if (groupType != null)
                {
                    // Warn if this GroupType or any of its child grouptypes (recursive) is being used as an Inherited Group Type. Probably shouldn't happen, but just in case
                    if (IsInheritedGroupTypeRecursive(groupType, groupTypeService))
                    {
                        nbDeleteWarning.Text    = "WARNING - Cannot delete. This group type or one of its child group types is assigned as an inherited group type.";
                        nbDeleteWarning.Visible = true;
                        return;
                    }

                    string errorMessage;
                    if (!groupTypeService.CanDelete(groupType, out errorMessage))
                    {
                        nbDeleteWarning.Text    = "WARNING - Cannot Delete: " + errorMessage;
                        nbDeleteWarning.Visible = true;
                        return;
                    }

                    int id = groupType.Id;

                    groupType.ParentGroupTypes.Clear();
                    groupType.ChildGroupTypes.Clear();

                    groupTypeService.Delete(groupType);
                    rockContext.SaveChanges();

                    GroupTypeCache.Flush(id);
                    Rock.CheckIn.KioskDevice.FlushAll();

                    SelectArea(null);
                }
            }

            BuildRows();
        }
示例#7
0
        /// <summary>
        /// Handles the Delete event of the gGroupType 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 gGroupType_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                GroupTypeService groupTypeService = new GroupTypeService();
                GroupType groupType = groupTypeService.Get(e.RowKeyId);

                if (groupType != null)
                {
                    string errorMessage;
                    if (!groupTypeService.CanDelete(groupType, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    groupTypeService.Delete(groupType, CurrentPersonId);
                    groupTypeService.Save(groupType, CurrentPersonId);
                }
            });

            BindGrid();
        }