GetNewFromTemplate() public method

Create a new non-persisted Report using an existing Report as a template.
public GetNewFromTemplate ( int reportId ) : Report
reportId int The identifier of a Report to use as a template for the new Report.
return Report
Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the Copy button 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 btnCopy_Click( object sender, EventArgs e )
        {
            // Create a new Report using the current item as a template.
            var id = int.Parse( hfReportId.Value );

            var reportService = new ReportService( new RockContext() );

            var newItem = reportService.GetNewFromTemplate( id );

            if (newItem == null)
            {
                return;
            }

            newItem.Name += " (Copy)";

            // Reset the stored identifier for the active Report.
            hfReportId.Value = "0";

            ShowEditDetails( newItem );
        }