Exemplo n.º 1
0
        /// <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)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                var competencyPersonProjectService = new ResidencyService <CompetencyPersonProject>();
                CompetencyPersonProject competencyPersonProject = competencyPersonProjectService.Get((int)e.RowKeyValue);

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

                    competencyPersonProjectService.Delete(competencyPersonProject, CurrentPersonId);
                    competencyPersonProjectService.Save(competencyPersonProject, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 2
0
        /// <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)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                BinaryFileTypeService binaryFileTypeService = new BinaryFileTypeService();
                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, CurrentPersonId);
                    binaryFileTypeService.Save(binaryFileType, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Delete event of the gPrayerComments 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 gPrayerComments_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                NoteService noteService = new NoteService();
                Note note = noteService.Get((int)e.RowKeyValues["id"]);

                if (note != null)
                {
                    string errorMessage;
                    if (!noteService.CanDelete(note, out errorMessage))
                    {
                        maGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    noteService.Delete(note, CurrentPersonId);
                    noteService.Save(note, CurrentPersonId);
                }
            });

            BindCommentsGrid();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles the Delete event of the gDevice 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 gDevice_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                DeviceService DeviceService = new DeviceService();
                Device Device = DeviceService.Get((int)e.RowKeyValue);

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

                    DeviceService.Delete(Device, CurrentPersonId);
                    DeviceService.Save(Device, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the Delete event of the gPrayerRequests 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 gPrayerRequests_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                PrayerRequestService prayerRequestService = new PrayerRequestService();
                PrayerRequest prayerRequest = prayerRequestService.Get((int)e.RowKeyValue);

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

                    prayerRequestService.Delete(prayerRequest, CurrentPersonId);
                    prayerRequestService.Save(prayerRequest, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 6
0
        /// <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)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                WorkflowTriggerService WorkflowTriggerService = new WorkflowTriggerService();
                WorkflowTrigger WorkflowTrigger = WorkflowTriggerService.Get((int)e.RowKeyValue);

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

                    WorkflowTriggerService.Delete(WorkflowTrigger, CurrentPersonId);
                    WorkflowTriggerService.Save(WorkflowTrigger, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles the Delete event of the gGroupRoles 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 gGroupRoles_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                GroupRoleService groupRoleService = new GroupRoleService();
                GroupRole groupRole = groupRoleService.Get((int)e.RowKeyValue);

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

                    groupRoleService.Delete(groupRole, CurrentPersonId);
                    groupRoleService.Save(groupRole, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 8
0
        /// <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)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                BlockTypeService blockTypeService = new BlockTypeService();
                BlockType blockType = blockTypeService.Get((int)e.RowKeyValue);
                if (blockType != null)
                {
                    string errorMessage;
                    if (!blockTypeService.CanDelete(blockType, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    blockTypeService.Delete(blockType, CurrentPersonId);
                    blockTypeService.Save(blockType, CurrentPersonId);
                    Rock.Web.Cache.BlockTypeCache.Flush(blockType.Id);
                }
            });

            BindGrid();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaignAdType 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 gMarketingCampaignAdType_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                MarketingCampaignAdTypeService marketingCampaignAdTypeService = new MarketingCampaignAdTypeService();
                MarketingCampaignAdType marketingCampaignAdType = marketingCampaignAdTypeService.Get((int)e.RowKeyValue);

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

                    marketingCampaignAdTypeService.Delete(marketingCampaignAdType, CurrentPersonId);
                    marketingCampaignAdTypeService.Save(marketingCampaignAdType, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 10
0
        /// <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)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                var periodService = new ResidencyService <Period>();

                Period period = periodService.Get((int)e.RowKeyValue);
                if (period != null)
                {
                    string errorMessage;
                    if (!periodService.CanDelete(period, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    periodService.Delete(period, CurrentPersonId);
                    periodService.Save(period, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 11
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)
        {
            int?categoryId = null;

            var reportService = new ReportService();
            var report        = reportService.Get(int.Parse(hfReportId.Value));

            if (report != null)
            {
                string errorMessage;
                if (!reportService.CanDelete(report, out errorMessage))
                {
                    ShowReadonlyDetails(report);
                    mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }
                else
                {
                    categoryId = report.CategoryId;

                    RockTransactionScope.WrapTransaction(() =>
                    {
                        reportService.Delete(report, CurrentPersonId);
                        reportService.Save(report, CurrentPersonId);
                    });

                    // reload page, selecting the deleted data view's parent
                    var qryParams = new Dictionary <string, string>();
                    if (categoryId != null)
                    {
                        qryParams["categoryId"] = categoryId.ToString();
                    }

                    NavigateToPage(RockPage.Guid, qryParams);
                }
            }
        }
Exemplo n.º 12
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)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                SiteService siteService = new SiteService();
                Site site = siteService.Get(int.Parse(hfSiteId.Value));
                if (site != null)
                {
                    string errorMessage;
                    if (!siteService.CanDelete(site, out errorMessage))
                    {
                        mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    siteService.Delete(site, CurrentPersonId);
                    siteService.Save(site, CurrentPersonId);

                    SiteCache.Flush(site.Id);
                }
            });

            NavigateToParentPage();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Handles the Click event of the btnSave 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 btnSave_Click(object sender, EventArgs e)
        {
            BinaryFile        binaryFile;
            BinaryFileService binaryFileService = new BinaryFileService();
            AttributeService  attributeService  = new AttributeService();

            int binaryFileId = int.Parse(hfBinaryFileId.Value);

            if (binaryFileId == 0)
            {
                binaryFile = new BinaryFile();
                binaryFileService.Add(binaryFile, CurrentPersonId);
            }
            else
            {
                binaryFile = binaryFileService.Get(binaryFileId);
            }

            // if a new file was uploaded, copy the uploaded file to this binaryFile (uploaded files are always new temporary binaryFiles)
            if (fsFile.BinaryFileId != binaryFile.Id)
            {
                var uploadedBinaryFile = binaryFileService.Get(fsFile.BinaryFileId ?? 0);
                if (uploadedBinaryFile != null)
                {
                    binaryFile.BinaryFileTypeId = uploadedBinaryFile.BinaryFileTypeId;
                    if (uploadedBinaryFile.Data != null)
                    {
                        binaryFile.Data         = binaryFile.Data ?? new BinaryFileData();
                        binaryFile.Data.Content = uploadedBinaryFile.Data.Content;
                    }
                }
            }

            binaryFile.IsTemporary      = false;
            binaryFile.FileName         = tbName.Text;
            binaryFile.Description      = tbDescription.Text;
            binaryFile.MimeType         = tbMimeType.Text;
            binaryFile.BinaryFileTypeId = ddlBinaryFileType.SelectedValueAsInt();

            binaryFile.LoadAttributes();
            Rock.Attribute.Helper.GetEditValues(phAttributes, binaryFile);

            if (!Page.IsValid)
            {
                return;
            }

            if (!binaryFile.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            RockTransactionScope.WrapTransaction(() =>
            {
                binaryFileService.Save(binaryFile, CurrentPersonId);
                Rock.Attribute.Helper.SaveAttributeValues(binaryFile, CurrentPersonId);
            });

            NavigateToParentPage();
        }