Beispiel #1
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 )
        {
            var rockContext = new RockContext();
            DeviceService DeviceService = new DeviceService( rockContext );
            Device Device = DeviceService.Get( e.RowKeyId );

            if ( Device != null )
            {
                int deviceId = Device.Id;

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

                DeviceService.Delete( Device );
                rockContext.SaveChanges();

                Rock.CheckIn.KioskDevice.Flush( deviceId );
            }

            BindGrid();
        }
Beispiel #2
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();
        }