Event argument used by the Grid events
Inheritance: System.EventArgs
Example #1
0
 /// <summary>
 /// Raises the <see cref="E:Click"/> event.
 /// </summary>
 /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
 public virtual void OnClick( RowEventArgs e )
 {
     if ( Click != null )
     {
         Click( this, e );
     }
 }
        /// <summary>
        /// Handles the Delete event of the gSignatureDocumentTemplate 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 gSignatureDocumentTemplate_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var signatureDocumentService = new SignatureDocumentService( rockContext );
            var signatureDocumentTemplateService = new SignatureDocumentTemplateService( rockContext );

            SignatureDocumentTemplate type = signatureDocumentTemplateService.Get( e.RowKeyId );

            if ( type != null )
            {
                if ( !UserCanEdit && !type.IsAuthorized( Authorization.EDIT, CurrentPerson ) )
                {
                    mdGridWarning.Show( "Sorry, you're not authorized to delete this signature document template.", ModalAlertType.Alert );
                    return;
                }

                string errorMessage;
                if ( !signatureDocumentTemplateService.CanDelete( type, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                signatureDocumentTemplateService.Delete( type );

                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gSites 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 gSites_Delete( object sender, RowEventArgs e )
        {
            bool canDelete = false;

            var rockContext = new RockContext();
            SiteService siteService = new SiteService( rockContext );
            Site site = siteService.Get( e.RowKeyId );
            if ( site != null )
            {
                string errorMessage;
                canDelete = siteService.CanDelete( site, out errorMessage, includeSecondLvl: true );
                if ( !canDelete )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
                    return;
                }

                siteService.Delete( site );

                rockContext.SaveChanges();

                SiteCache.Flush( site.Id );
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gBinaryFile 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 gBinaryFile_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            BinaryFileService binaryFileService = new BinaryFileService( rockContext );
            BinaryFile binaryFile = binaryFileService.Get( e.RowKeyId );

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

                Guid guid = binaryFile.Guid;
                bool clearDeviceCache = binaryFile.BinaryFileType.Guid.Equals( Rock.SystemGuid.BinaryFiletype.CHECKIN_LABEL.AsGuid() );

                binaryFileService.Delete( binaryFile );
                rockContext.SaveChanges();

                if ( clearDeviceCache )
                {
                    Rock.CheckIn.KioskDevice.FlushAll();
                    Rock.CheckIn.KioskLabel.Flush( guid );
                }
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gContentChannels 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 gContentChannels_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            ContentChannelService contentChannelService = new ContentChannelService( rockContext );

            ContentChannel contentChannel = contentChannelService.Get( e.RowKeyId );

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

                contentChannel.ParentContentChannels.Clear();
                contentChannel.ChildContentChannels.Clear();

                contentChannelService.Delete( contentChannel );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Example #6
0
        /// <summary>
        /// Handles the Delete event of the gCampuses 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 gCampuses_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            CampusService campusService = new CampusService( rockContext );
            Campus campus = campusService.Get( e.RowKeyId );
            if ( campus != null )
            {
                // Don't allow deleting the last campus
                if ( !campusService.Queryable().Where( c => c.Id != campus.Id ).Any() )
                {
                    mdGridWarning.Show( campus.Name + " is the only campus and cannot be deleted (Rock requires at least one campus).", ModalAlertType.Information );
                    return;
                }

                string errorMessage;
                if ( !campusService.CanDelete( campus, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                CampusCache.Flush( campus.Id );

                campusService.Delete( campus );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Example #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 )
        {
            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();
        }
Example #8
0
        protected void gWdigityItemAttributes_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var toRemove = WidgityItemAttributes.Where(a => a.Guid == ( Guid )e.RowKeyValue).FirstOrDefault();

            if (toRemove != null)
            {
                WidgityItemAttributes.Remove(toRemove);
                SaveState();
            }
        }
Example #9
0
        /// <summary>
        /// Handles the Click event of the gIncludedAttributesDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gIncludedAttributesDelete_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var settingKey = e.RowKeyValue.ToString();

            var setting = this.FieldSettings.Where(s => s.Key == settingKey).FirstOrDefault();

            _fieldSettings.Remove(setting);

            BindFieldGrid();
        }
        /// <summary>
        /// Handles the Edit event of the gTransactions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gTransactions_Edit(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            if (_batch != null && _batch.Status != BatchStatus.Open)
            {
                BindGrid();
                return;
            }

            ShowDetailForm((int)e.RowKeyValue);
        }
Example #11
0
        /// <summary>
        /// Handles the RowSelected event of the gReport control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gReport_RowSelected(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            int id = int.MinValue;

            if (TagEntityType != null && int.TryParse(e.RowKeyValue.ToString(), out id))
            {
                string routePath = string.Format("~/{0}/{1}", TagEntityType.FriendlyName.Replace(" ", ""), id);
                Response.Redirect(routePath, false);
            }
        }
Example #12
0
        /// <summary>
        /// Handles the Delete event of the gTransactions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param>
        protected void gTransactions_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext        = new RockContext();
            var transactionService = new FinancialTransactionService(rockContext);
            var transaction        = transactionService.Get(e.RowKeyId);

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

                // prevent deleting a Transaction that is in closed batch
                if (transaction.Batch != null)
                {
                    if (transaction.Batch.Status == BatchStatus.Closed)
                    {
                        mdGridWarning.Show(string.Format("This {0} is assigned to a closed {1}", FinancialTransaction.FriendlyTypeName, FinancialBatch.FriendlyTypeName), ModalAlertType.Information);
                        return;
                    }
                }

                if (transaction.BatchId.HasValue)
                {
                    string caption = (transaction.AuthorizedPersonAlias != null && transaction.AuthorizedPersonAlias.Person != null) ?
                                     transaction.AuthorizedPersonAlias.Person.FullName :
                                     string.Format("Transaction: {0}", transaction.Id);

                    HistoryService.SaveChanges(
                        rockContext,
                        typeof(FinancialBatch),
                        Rock.SystemGuid.Category.HISTORY_FINANCIAL_TRANSACTION.AsGuid(),
                        transaction.BatchId.Value,
                        new List <string> {
                        "Deleted transaction"
                    },
                        caption,
                        typeof(FinancialTransaction),
                        transaction.Id,
                        false
                        );
                }

                transactionService.Delete(transaction);

                rockContext.SaveChanges();

                RockPage.UpdateBlocks("~/Blocks/Finance/BatchDetail.ascx");
            }

            BindGrid();
        }
        protected void SelectMember_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            RockContext         rockContext         = new RockContext();
            WorkflowTypeService workflowTypeService = new WorkflowTypeService(rockContext);
            var groupMemberGuid = (( Guid )e.RowKeyValue).ToString();
            var workflowGuid    = GetAttributeValue("EditWorkflow");
            var workflowId      = workflowTypeService.Get(workflowGuid.AsGuid()).Id.ToString();

            NavigateToLinkedPage("WorkflowPage", new Dictionary <string, string> {
                { "WorkflowTypeId", workflowId }, { "GroupMemberGuid", groupMemberGuid }
            });
        }
Example #14
0
        protected void rGrid_Delete( object sender, RowEventArgs e )
        {
            Rock.CMS.Block block = _blockService.Get( ( int )rGrid.DataKeys[e.RowIndex]["id"] );
            if ( BlockInstance != null )
            {
                _blockService.Delete( block, CurrentPersonId );
                _blockService.Save( block, CurrentPersonId );

                Rock.Web.Cache.Block.Flush( block.Id );
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the RowSelected event of the gReport 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 gReport_RowSelected( object sender, RowEventArgs e )
        {
            string url = GetAttributeValue( "UrlMask" );
            if ( !string.IsNullOrWhiteSpace( url ) )
            {
                foreach ( string key in gReport.DataKeyNames )
                {
                    url = url.Replace( "{" + key + "}", gReport.DataKeys[e.RowIndex][key].ToString() );
                }

                Response.Redirect( url, false );
            }
        }
Example #16
0
        /// <summary>
        /// Handles the Click event of the DeleteFamilyMember control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void DeleteFamilyMember_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            if (CurrentCheckInState == null)
            {
                // OnLoad would have started a 'NavigateToHomePage', so just jump out
                return;
            }

            var familyPersonState = EditFamilyState.FamilyPersonListState.FirstOrDefault(a => a.GroupMemberGuid == ( Guid )e.RowKeyValue);

            familyPersonState.IsDeleted = true;
            BindFamilyMembersGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gEmailTemplates 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 gEmailTemplates_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            SystemEmailService emailTemplateService = new SystemEmailService( rockContext );
            SystemEmail emailTemplate = emailTemplateService.Get( (int)gEmailTemplates.DataKeys[e.RowIndex]["id"] );
            if ( emailTemplate != null )
            {
                emailTemplateService.Delete( emailTemplate );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Example #18
0
        /// <summary>
        /// Handles the Delete event of the rGridTransactions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void rGridTransactions_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var financialTransactionService = new Rock.Model.FinancialTransactionService();

            FinancialTransaction financialTransaction = financialTransactionService.Get((int)e.RowKeyValue);

            if (financialTransaction != null)
            {
                financialTransactionService.Delete(financialTransaction, CurrentPersonId);
                financialTransactionService.Save(financialTransaction, CurrentPersonId);
            }

            BindGrid();
        }
Example #19
0
        /// <summary>
        /// Handles the Delete event of the gBusinessList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gBusinessList_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var           rockContext = new RockContext();
            PersonService service     = new PersonService(rockContext);
            Person        business    = service.Get(e.RowKeyId);

            if (business != null)
            {
                business.RecordStatusValueId = DefinedValueCache.Read(new Guid(Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE)).Id;
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Example #20
0
        /// <summary>
        /// Handles the Delete event of the gHistory control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gHistory_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                var service    = new AttendanceService(rockContext);
                var attendance = service.Get(e.RowKeyId);
                if (attendance != null)
                {
                    service.Delete(attendance);
                    rockContext.SaveChanges();
                }
            }

            ShowDetail(GetPersonGuid());
        }
Example #21
0
        protected void gHistory_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                var service    = new AttendanceService(rockContext);
                var attendance = service.Get(e.RowKeyId);
                if (attendance != null)
                {
                    service.Delete(attendance);
                    rockContext.SaveChanges();
                }
            }

            ShowDetail(PageParameter(PERSON_GUID_PAGE_QUERY_KEY).AsGuid());
        }
Example #22
0
        /// <summary>
        /// Handles the user clicking the delete button in the gAttendees 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 gAttendeesDelete_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext       = new RockContext();
            var attendanceService = new AttendanceService(rockContext);
            var attendance        = attendanceService.Get(e.RowKeyId);

            attendance.DidAttend = false;
            rockContext.SaveChanges();

            if (attendance.Occurrence.LocationId != null)
            {
                Rock.CheckIn.KioskLocationAttendance.Remove(attendance.Occurrence.LocationId.Value);
            }

            BindGrid();
        }
 /// <summary>
 /// Handles the Copy event of the gCalendarItemOccurrenceList 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 gCalendarItemOccurrenceList_Copy( object sender, RowEventArgs e )
 {
     using ( RockContext rockContext = new RockContext() )
     {
         EventItemOccurrenceService eventItemOccurrenceService = new EventItemOccurrenceService( rockContext );
         EventItemOccurrence eventItemOccurrence = eventItemOccurrenceService.Get( e.RowKeyId );
         if ( eventItemOccurrence != null )
         {
             var qryParams = new Dictionary<string, string>();
             qryParams.Add( "EventCalendarId", PageParameter( "EventCalendarId" ) );
             qryParams.Add( "EventItemId", _eventItem.Id.ToString() );
             qryParams.Add( "EventItemOccurrenceId", "0" );
             qryParams.Add( "CopyFromId", eventItemOccurrence.Id.ToString() );
             NavigateToLinkedPage( "DetailPage", qryParams );
         }
     }
 }
Example #24
0
        /// <summary>
        /// Handles the Click event of the gCompileTheme 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 gCompileTheme_Click( object sender, RowEventArgs e )
        {
            var theme = new RockTheme( e.RowKeyValue.ToString() );
            string messages = string.Empty;

            bool compileSuccess = theme.Compile( out messages );

            if ( compileSuccess )
            {
                mdThemeCompile.Show( "Theme was successfully compiled.", ModalAlertType.Information );
            }
            else
            {
                nbMessages.NotificationBoxType = NotificationBoxType.Danger;
                nbMessages.Text = string.Format( "An error occurred while compiling the {0} them. Message: {1}", theme.Name, messages );
            }
        }
        protected void attendanceDelete_Click(object sender, RowEventArgs e)
        {
            RockContext editContext = new RockContext();
            AttendanceService editAttServe = new AttendanceService(editContext);

            var attendItem = editAttServe.Queryable().Where(x => x.Id == e.RowKeyId).FirstOrDefault();
            if (attendItem.IsAuthorized("Edit", CurrentPerson))
            {
                attendItem.DidAttend = !attendItem.DidAttend;
                attendItem.DidNotOccur = !attendItem.DidAttend;
                editContext.SaveChanges();
            }

            _rockContext = new RockContext();
            attendServ = new AttendanceService(_rockContext);
            doStuff();
        }
        /// <summary>
        /// Handles the Click event of the gContentItemBulkLoad 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 gBulkLoad_Click( object sender, RowEventArgs e )
        {
            var entityType = EntityTypeCache.Read( e.RowKeyId );

            if (entityType != null )
            {
                BulkIndexEntityTypeTransaction bulkIndexTransaction = new BulkIndexEntityTypeTransaction();
                bulkIndexTransaction.EntityTypeId = entityType.Id;

                RockQueue.TransactionQueue.Enqueue( bulkIndexTransaction );

                maMessages.Show( string.Format("A request has been sent to index {0}.", entityType.FriendlyName.Pluralize()), ModalAlertType.Information );
            }
            else
            {
                maMessages.Show( "An error occurred launching the bulk index request. Could not find the entity type.", ModalAlertType.Alert );
            }
        }
Example #27
0
        /// <summary>
        /// Handles the RowSelected event of the gReport control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gReport_RowSelected(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            Guid guid = Guid.Empty;

            if (TagEntityType != null && Guid.TryParse(e.RowKeyValue.ToString(), out guid))
            {
                object entity = InvokeServiceMethod("Get", new Type[] { typeof(Guid) }, new object[] { guid });
                if (entity != null)
                {
                    Rock.Data.IEntity model = entity as Rock.Data.IEntity;
                    if (model != null)
                    {
                        string routePath = string.Format("~/{0}/{1}", TagEntityType.FriendlyName.Replace(" ", ""), model.Id);
                        Response.Redirect(routePath, false);
                    }
                }
            }
        }
        /// <summary>
        /// Handles the Delete event of the grdScheduledJobs 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 gScheduledJobs_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var jobService = new ServiceJobService( rockContext );
            ServiceJob job = jobService.Get( e.RowKeyId );

            string errorMessage;
            if ( !jobService.CanDelete( job, out errorMessage ) )
            {
                mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                return;
            }

            jobService.Delete( job );
            rockContext.SaveChanges();

            BindGrid();
        }
Example #29
0
        /// <summary>
        /// Handles the Delete event of the gFollowings 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 gFollowings_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var service = new FollowingService( rockContext );

            int personEntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
            foreach (var following in service.Queryable()
                .Where( f =>
                    f.EntityTypeId == personEntityTypeId &&
                    f.EntityId == e.RowKeyId &&
                    f.PersonAliasId == CurrentPersonAlias.Id ) )
            {
                service.Delete( following );
            }

            rockContext.SaveChanges();

            BindGrid();
        }
Example #30
0
        /// <summary>
        /// Handles the Delete event of the gContactList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gContactList_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            int?businessId = hfBusinessId.Value.AsIntegerOrNull();

            if (businessId.HasValue)
            {
                var businessContactId = e.RowKeyId;

                var rockContext        = new RockContext();
                var groupMemberService = new GroupMemberService(rockContext);

                Guid businessContact = Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_BUSINESS_CONTACT.AsGuid();
                Guid business        = Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_BUSINESS.AsGuid();
                Guid ownerGuid       = Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER.AsGuid();
                foreach (var groupMember in groupMemberService.Queryable()
                         .Where(m =>
                                (
                                    // The contact person in the business's known relationships
                                    m.PersonId == businessContactId &&
                                    m.GroupRole.Guid.Equals(businessContact) &&
                                    m.Group.Members.Any(o =>
                                                        o.PersonId == businessId &&
                                                        o.GroupRole.Guid.Equals(ownerGuid))
                                ) ||
                                (
                                    // The business in the person's know relationships
                                    m.PersonId == businessId &&
                                    m.GroupRole.Guid.Equals(business) &&
                                    m.Group.Members.Any(o =>
                                                        o.PersonId == businessContactId &&
                                                        o.GroupRole.Guid.Equals(ownerGuid))
                                )
                                ))
                {
                    groupMemberService.Delete(groupMember);
                }

                rockContext.SaveChanges();

                BindContactListGrid(new PersonService(rockContext).Get(businessId.Value));
            }
        }
        /// <summary>
        /// Handles the Delete event of the gWorkflows 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 gWorkflows_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            WorkflowService workflowService = new WorkflowService( rockContext );
            Workflow workflow = workflowService.Get( (int)e.RowKeyValue );
            if ( workflow != null )
            {
                string errorMessage;
                if ( !workflowService.CanDelete( workflow, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                workflowService.Delete( workflow );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gBatchList 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 gBatchList_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            FinancialBatchService financialBatchService = new FinancialBatchService( rockContext );
            FinancialBatch financialBatch = financialBatchService.Get( e.RowKeyId );
            if ( financialBatch != null )
            {
                string errorMessage;
                if ( !financialBatchService.CanDelete( financialBatch, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                financialBatchService.Delete( financialBatch );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gMetricValues 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 gMetricValues_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            MetricValueService metricValueService = new MetricValueService( rockContext );
            MetricValue metricValue = metricValueService.Get( e.RowKeyId );
            if ( metricValue != null )
            {
                string errorMessage;
                if ( !metricValueService.CanDelete( metricValue, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                metricValueService.Delete( metricValue );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gRestKeyList 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 gRestKeyList_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var personService = new PersonService( rockContext );
            var userLoginService = new UserLoginService( rockContext );
            var restUser = personService.Get( e.RowKeyId );
            if ( restUser != null )
            {
                restUser.RecordStatusValueId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ) ).Id;

                // remove all user logins for key
                foreach ( var login in restUser.Users.ToList() )
                {
                    userLoginService.Delete( login );
                }
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gCampuses 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 gCampuses_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            CampusService campusService = new CampusService( rockContext );
            Campus campus = campusService.Get( (int)e.RowKeyValue );
            if ( campus != null )
            {
                string errorMessage;
                if ( !campusService.CanDelete( campus, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                campusService.Delete( campus );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gAgencies 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 gAgencies_Delete( object sender, RowEventArgs e )
        {
            var dataContext = new SampleProjectContext();
            var service = new ReferralAgencyService( dataContext );
            var referralAgency = service.Get( (int)e.RowKeyValue );
            if ( referralAgency != null )
            {
                string errorMessage;
                if ( !service.CanDelete( referralAgency, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                service.Delete( referralAgency );
                dataContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gSchedules 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 gSchedules_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            ScheduleService scheduleService = new ScheduleService( rockContext );
            Schedule schedule = scheduleService.Get( e.RowKeyId );
            if ( schedule != null )
            {
                string errorMessage;
                if ( !scheduleService.CanDelete( schedule, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                scheduleService.Delete( schedule );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gList 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 gList_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            GroupRequirementTypeService service = new GroupRequirementTypeService( rockContext );
            GroupRequirementType item = service.Get( e.RowKeyId );
            if ( item != null )
            {
                string errorMessage;
                if ( !service.CanDelete( item, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                service.Delete( item );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gDefinedType 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 gDefinedType_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var definedValueService = new DefinedValueService( rockContext );
            var definedTypeService = new DefinedTypeService( rockContext );

            DefinedType type = definedTypeService.Get( e.RowKeyId );

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

                // if this DefinedType has DefinedValues, see if they can be deleted
                var definedValues = definedValueService.GetByDefinedTypeId( type.Id ).ToList();

                foreach ( var value in definedValues )
                {
                    if ( !definedValueService.CanDelete( value, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }
                }

                foreach ( var value in definedValues )
                {
                    definedValueService.Delete( value );
                }

                definedTypeService.Delete( type );

                rockContext.SaveChanges();
            }

            gDefinedType_Bind();
        }
Example #40
0
        /// <summary>
        /// Handles the Remove event of the gCommunication control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gCommunication_Remove(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext          = new RockContext();
            var communicationService = new CommunicationService(rockContext);
            var communication        = communicationService.Get(e.RowKeyId);

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

                if (!communication.ForeignGuid.HasValue)
                {
                    mdGridWarning.Show("Unable to delete this communication from Subsplash.  The ForeignGuid is missing.", ModalAlertType.Warning);
                    return;
                }

                // Load the notifications using the Push Notifications Transport
                var transport = TransportContainer.Instance.Components.FirstOrDefault(t => t.Value.Value.TypeGuid == GetAttributeValue("Transport").AsGuidOrNull()).Value.Value;
                if (transport != null)
                {
                    transport.LoadAttributes();

                    var client = new RestClient(transport.GetAttributeValue("APIEndpoint"));

                    var pushNotificationRequest = new RestRequest("notifications/{id}", Method.DELETE);
                    pushNotificationRequest.AddHeader("Content-Type", "application/json");
                    pushNotificationRequest.AddHeader("Authorization", "Bearer " + Encryption.DecryptString(transport.GetAttributeValue("JWTToken")));
                    pushNotificationRequest.AddParameter("id", communication.ForeignGuid.ToString(), ParameterType.UrlSegment);
                    pushNotificationRequest.RequestFormat = DataFormat.Json;

                    var response = client.Execute(pushNotificationRequest);
                }
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gBinaryFileType 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 gBinaryFileType_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            BinaryFileTypeService binaryFileTypeService = new BinaryFileTypeService( rockContext );
            BinaryFileType binaryFileType = binaryFileTypeService.Get( e.RowKeyId );

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

                binaryFileTypeService.Delete( binaryFileType );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the DeleteClick event of the gElementList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gElementList_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext         = new RockContext();
            var mediaElementService = new MediaElementService(rockContext);
            var mediaElement        = mediaElementService.Get(e.RowKeyId);

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

                mediaElementService.Delete(mediaElement);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gBlockTypes 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 gBlockTypes_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            BlockTypeService blockTypeService = new BlockTypeService( rockContext );
            BlockType blockType = blockTypeService.Get( e.RowKeyId );
            if ( blockType != null )
            {
                string errorMessage;
                if ( !blockTypeService.CanDelete( blockType, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                blockTypeService.Delete( blockType );
                rockContext.SaveChanges();
                Rock.Web.Cache.BlockTypeCache.Flush( blockType.Id );
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gWorkflowTrigger 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 gWorkflowTrigger_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            WorkflowTriggerService WorkflowTriggerService = new WorkflowTriggerService( rockContext );
            WorkflowTrigger WorkflowTrigger = WorkflowTriggerService.Get( e.RowKeyId );

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

                WorkflowTriggerService.Delete( WorkflowTrigger );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Example #45
0
        /// <summary>
        /// Handles the Delete click event for the grid.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param>
        protected void DeleteBlock_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var          rockContext  = new RockContext();
            BlockService blockService = new BlockService(rockContext);
            Block        block        = blockService.Get(e.RowKeyId);

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

                blockService.Delete(block);
                rockContext.SaveChanges();
            }

            BindLayoutBlocksGrid();
        }
Example #46
0
        /// <summary>
        /// Handles the DeleteClick event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gList_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext = new RockContext();
            PersistedDatasetService persistedDatasetService = new PersistedDatasetService(rockContext);
            PersistedDataset        persistedDataset        = persistedDatasetService.Get(e.RowKeyId);

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

                persistedDatasetService.Delete(persistedDataset);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaignAds 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 gMarketingCampaignAds_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            MarketingCampaignAdService marketingCampaignAdService = new MarketingCampaignAdService( rockContext );

            MarketingCampaignAd marketingCampaignAd = marketingCampaignAdService.Get( e.RowKeyId );
            if ( marketingCampaignAd != null )
            {
                string errorMessage;
                if ( !marketingCampaignAdService.CanDelete( marketingCampaignAd, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                marketingCampaignAdService.Delete( marketingCampaignAd );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gTransactions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param>
        protected void gTransactions_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext = new RockContext();
            FinancialTransactionService service = new FinancialTransactionService(rockContext);
            FinancialTransaction        item    = service.Get(e.RowKeyId);

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

                service.Delete(item);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
        /// <summary>
        /// Handles the DeleteClick event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gList_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext = new RockContext();
            GroupMemberScheduleTemplateService groupMemberScheduleTemplateService = new GroupMemberScheduleTemplateService(rockContext);
            GroupMemberScheduleTemplate        groupMemberScheduleTemplate        = groupMemberScheduleTemplateService.Get(e.RowKeyId);

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

                groupMemberScheduleTemplateService.Delete(groupMemberScheduleTemplate);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Example #50
0
    /// <summary>
    /// Handles the Delete event of the gGroups 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 gGroups_Delete( object sender, RowEventArgs e )
    {
        RockTransactionScope.WrapTransaction( () =>
            {
                GroupService groupService = new GroupService();
                AuthService authService = new AuthService();
                Group group = groupService.Get( (int)e.RowKeyValue );

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

                    bool isSecurityRoleGroup = group.IsSecurityRole;
                    if ( isSecurityRoleGroup )
                    {
                        foreach ( var auth in authService.Queryable().Where( a => a.GroupId.Equals( group.Id ) ).ToList() )
                        {
                            authService.Delete( auth, CurrentPersonId );
                            authService.Save( auth, CurrentPersonId );
                        }
                    }

                    groupService.Delete( group, CurrentPersonId );
                    groupService.Save( group, CurrentPersonId );

                    if ( isSecurityRoleGroup )
                    {
                        Rock.Security.Authorization.Flush();
                        Rock.Security.Role.Flush( group.Id );
                    }
                }
            } );

        BindGrid();
    }
        /// <summary>
        /// Handles the Delete event of the 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 gFileFormat_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext       = new RockContext();
            var fileFormatService = new ImageCashLetterFileFormatService(rockContext);
            var fileFormat        = fileFormatService.Get(e.RowKeyId);

            if (fileFormat != null)
            {
                int fileFormatId = fileFormat.Id;

                if (!fileFormat.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson))
                {
                    mdGridWarning.Show("Sorry, you're not authorized to delete this file format.", ModalAlertType.Alert);
                    return;
                }

                fileFormatService.Delete(fileFormat);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Example #52
0
        /// <summary>
        /// Handles the Delete event of the gFormTemplates 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 gFormTemplates_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                int templateId      = ( int )e.RowKeyValue;
                var workflowService = new WorkflowService(rockContext);
                var hasTemplates    = workflowService.Queryable().Any(wf => wf.WorkflowType.FormBuilderTemplateId == templateId);
                if (hasTemplates)
                {
                    ShowAlert("This template has workflows assigned to it", ModalAlertType.Warning);
                }
                else
                {
                    var formTemplateService = new WorkflowFormBuilderTemplateService(rockContext);
                    var template            = formTemplateService.Get(templateId);
                    formTemplateService.Delete(template);
                    rockContext.SaveChanges();
                }
            }

            BindGrid();
        }
Example #53
0
        /// <summary>
        /// Handles the Delete event of the gCommunication control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gCommunication_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext          = new RockContext();
            var communicationService = new CommunicationService(rockContext);
            var communication        = communicationService.Get(e.RowKeyId);

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

                communicationService.Delete(communication);

                rockContext.SaveChanges();
            }

            BindGrid();
        }
Example #54
0
        /// <summary>
        /// Handles the DeleteClick event of the gBlockTypeAttributes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gBlockTypeAttributes_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            Guid             attributeGuid    = (Guid)e.RowKeyValue;
            var              rockContext      = new RockContext();
            AttributeService attributeService = new AttributeService(rockContext);
            Attribute        attribute        = attributeService.Get(attributeGuid);

            if (attribute != null)
            {
                string errorMessage;
                if (!attributeService.CanDelete(attribute, out errorMessage))
                {
                    mdGridWarningAttributes.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                attributeService.Delete(attribute);
                rockContext.SaveChanges();
            }

            BindBlockTypeAttributesGrid();
        }
Example #55
0
        /// <summary>
        /// Handles the Click event of the gPages control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gPages_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext = new RockContext();
            var pageService = new PageService(rockContext);
            var page        = pageService.Get(e.RowKeyId);

            if (page != null)
            {
                string errorMessage;
                if (!pageService.CanDelete(page, out errorMessage))
                {
                    mdWarning.Show(errorMessage, ModalAlertType.Warning);
                    return;
                }

                pageService.Delete(page);

                rockContext.SaveChanges();
            }

            BindPages();
        }
        /// <summary>
        /// Handles the Delete event of the gCommunication control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gCommunication_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                var communicationService = new CommunicationService();
                var communication        = communicationService.Get(e.RowKeyId);
                if (communication != null)
                {
                    string errorMessage;
                    if (!communicationService.CanDelete(communication, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    communicationService.Delete(communication, CurrentPersonId);
                    communicationService.Save(communication, CurrentPersonId);
                }
            });

            BindGrid();
        }
Example #57
0
        /// <summary>
        /// Handles the Click event of the DeleteGroupMember control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param>
        protected void DeleteGroupMember_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            RockContext        rockContext        = new RockContext();
            GroupMemberService groupMemberService = new GroupMemberService(rockContext);
            GroupMember        groupMember        = groupMemberService.Get(e.RowKeyId);

            if (groupMember != null)
            {
                string errorMessage;
                if (!groupMember.Group.IsAuthorized(Authorization.EDIT, this.CurrentPerson))
                {
                    errorMessage = "You're not authorized to remove this Person";
                    mdGridWarning.Show(errorMessage, ModalAlertType.Warning);
                    return;
                }

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

                int groupId = groupMember.GroupId;

                groupMemberService.Delete(groupMember);
                rockContext.SaveChanges();

                Group group = new GroupService(rockContext).Get(groupId);
                if (group.IsSecurityRole || group.GroupType.Guid.Equals(Rock.SystemGuid.GroupType.GROUPTYPE_SECURITY_ROLE.AsGuid()))
                {
                    // person removed from SecurityRole, Flush
                    Rock.Security.Role.Flush(group.Id);
                    Rock.Security.Authorization.Flush();
                }
            }

            BindGroupMembersGrid();
        }
Example #58
0
        /// <summary>
        /// Handles the Click event of the gIncludedAttributesEdit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gIncludedAttributesEdit_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var settingKey = e.RowKeyValue.ToString();

            var setting = this.FieldSettings.Where(s => s.Key == settingKey).FirstOrDefault();

            if (setting == null)
            {
                return;
            }

            pnlDataEdit.Visible         = true;
            gIncludedAttributes.Visible = false;

            // Set edit values
            rblFieldSource.SetValue(setting.FieldSource.ConvertToInt().ToString());
            tbKey.Text            = setting.Key;
            hfOriginalKey.Value   = setting.Key;
            ceLavaExpression.Text = setting.Value;


            if (setting.FieldSource == ContentChannelItemList.FieldSource.Property)
            {
                ddlContentChannelProperties.SelectedValue = setting.FieldName;
            }
            else if (setting.FieldSource == ContentChannelItemList.FieldSource.Attribute)
            {
                rblAttributeFormatType.SetValue(setting.AttributeFormat.ConvertToInt().ToString());
            }
            else
            {
                ceLavaExpression.Text = setting.Value;
                rblAttributeFormatType.SetValue(setting.AttributeFormat.ConvertToInt().ToString());
                rblFieldFormat.SetValue(setting.FieldFormat.ConvertToInt().ToString());
            }

            SetPropertyTypePanels();
        }
Example #59
0
        /// <summary>
        /// Handles the Delete event of the gTransactions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param>
        protected void gTransactions_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext        = new RockContext();
            var transactionService = new FinancialTransactionService(rockContext);
            var transaction        = transactionService.Get(e.RowKeyId);

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

                transactionService.Delete(transaction);
                rockContext.SaveChanges();

                RockPage.UpdateBlocks("~/Blocks/Finance/BatchDetail.ascx");
            }

            BindGrid();
        }
        protected void Distribute_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            RockContext rockContext  = new RockContext();
            NoteService noteService  = new NoteService(rockContext);
            var         keys         = (( string )e.RowKeyValue).SplitDelimitedValues();
            var         personId     = keys[0].AsInteger();
            var         matrixId     = keys[1].AsInteger();
            var         scheduleGuid = keys[2].AsGuid();

            AttributeMatrixItemService attributeMatrixItemService = new AttributeMatrixItemService(rockContext);
            var matrix = attributeMatrixItemService.Get(matrixId);

            matrix.LoadAttributes();
            var noteType = NoteTypeCache.Get(GetAttributeValue("NoteType").AsGuid());

            Note history = new Note()
            {
                NoteTypeId  = noteType.Id,
                EntityId    = personId,
                ForeignId   = matrixId,
                Caption     = "Medication Distributed",
                Text        = string.Format("<span class=\"field-name\">{0}</span> was distributed at <span class=\"field-name\">{1}</span>", matrix.GetAttributeValue("Medication"), Rock.RockDateTime.Now),
                ForeignGuid = scheduleGuid
            };

            noteService.Add(history);
            rockContext.SaveChanges();

            //for clicking distribute after the fact
            if (dpDate.SelectedDate.HasValue && dpDate.SelectedDate.Value.Date != Rock.RockDateTime.Today)
            {
                history.CreatedDateTime = dpDate.SelectedDate.Value;
                rockContext.SaveChanges();
            }

            BindGrid();
        }