コード例 #1
0
        protected void gRequests_Delete(object sender, RowEventArgs e)
        {
            using (RockContext rockContext = new RockContext())
            {
                var service           = new ConnectionRequestService(rockContext);
                var connectionRequest = service.Get(e.RowKeyId);
                if (connectionRequest != null)
                {
                    string errorMessage;
                    if (!service.CanDelete(connectionRequest, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    rockContext.WrapTransaction(() =>
                    {
                        new ConnectionRequestActivityService(rockContext).DeleteRange(connectionRequest.ConnectionRequestActivities);
                        service.Delete(connectionRequest);
                        rockContext.SaveChanges();
                    });
                }
            }

            BindGrid();
        }
コード例 #2
0
        protected void gRequests_Delete( object sender, RowEventArgs e )
        {
            using ( RockContext rockContext = new RockContext() )
            {
                var service = new ConnectionRequestService( rockContext );
                var connectionRequest = service.Get( e.RowKeyId );
                if ( connectionRequest != null )
                {
                    string errorMessage;
                    if ( !service.CanDelete( connectionRequest, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }

                    rockContext.WrapTransaction( () =>
                    {
                        new ConnectionRequestActivityService( rockContext ).DeleteRange( connectionRequest.ConnectionRequestActivities );
                        service.Delete( connectionRequest );
                        rockContext.SaveChanges();
                    } );
                }
            }

            BindGrid();
        }