Beispiel #1
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)
        {
            using (var rockContext = new RockContext())
            {
                FinancialGateway gateway = null;

                var gatewayService = new Rock.Model.FinancialGatewayService(rockContext);

                if (GatewayId != 0)
                {
                    gateway = gatewayService.Get(GatewayId);
                }

                if (gateway == null)
                {
                    gateway = new Rock.Model.FinancialGateway();
                    gatewayService.Add(gateway);
                }

                gateway.Name         = tbName.Text;
                gateway.IsActive     = cbIsActive.Checked;
                gateway.Description  = tbDescription.Text;
                gateway.EntityTypeId = cpGatewayType.SelectedEntityTypeId;
                gateway.SetBatchTimeOffset(tpBatchTimeOffset.SelectedTime);

                rockContext.SaveChanges();

                gateway.LoadAttributes(rockContext);
                Rock.Attribute.Helper.GetEditValues(phAttributes, gateway);
                gateway.SaveAttributeValues(rockContext);
            }

            NavigateToParentPage();
        }
        /// <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 )
        {
            using ( var rockContext = new RockContext() )
            {
                FinancialGateway gateway = null;

                var gatewayService = new Rock.Model.FinancialGatewayService( rockContext );

                if ( GatewayId != 0 )
                {
                    gateway = gatewayService.Get( GatewayId );
                }

                if ( gateway == null )
                {
                    gateway = new Rock.Model.FinancialGateway();
                    gatewayService.Add( gateway );
                }

                gateway.Name = tbName.Text;
                gateway.IsActive = cbIsActive.Checked;
                gateway.Description = tbDescription.Text;
                gateway.EntityTypeId = cpGatewayType.SelectedEntityTypeId;
                gateway.SetBatchTimeOffset( tpBatchTimeOffset.SelectedTime );

                rockContext.SaveChanges();

                gateway.LoadAttributes( rockContext );
                Rock.Attribute.Helper.GetEditValues( phAttributes, gateway );
                gateway.SaveAttributeValues( rockContext );
            }

            NavigateToParentPage();
        }