コード例 #1
0
 public void OnDeleteError(ActiveRecordDataSourceDeleteEventArgs e)
 {
     if (DeleteError != null)
     {
         DeleteError(this, e);
     }
 }
コード例 #2
0
 public void OnBeforeDelete(ActiveRecordDataSourceDeleteEventArgs e)
 {
     if (BeforeDelete != null)
     {
         BeforeDelete(this, e);
     }
 }
コード例 #3
0
        protected override int ExecuteDelete(IDictionary keys, IDictionary oldValues)
        {
            ActiveRecordDataSourceDeleteEventArgs args = new ActiveRecordDataSourceDeleteEventArgs();

            args.ModelType = BuildManager.GetType(Source.TypeName, false, true);

            IClassMetadata meta = ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(args.ModelType).GetClassMetadata(args.ModelType);

            if (!meta.HasIdentifierProperty)
            {
                throw new ApplicationException("ActiveRecordDataSourceView requires a primary key for the delete method.");
            }

            args.KeyProperty = meta.IdentifierPropertyName;
            args.KeyValue    = keys[meta.IdentifierPropertyName];

            try
            {
                args.Entity = ActiveRecordMediator.FindByPrimaryKey(args.ModelType, args.KeyValue);

                Source.OnBeforeDelete(args);

                if (args.Cancel)
                {
                    return(0);
                }

                ActiveRecordMediator.Delete(args.Entity);
            }
            catch (Exception e)
            {
                args.Exception = e;
                args.WasError  = true;

                Source.OnDeleteError(args);

                if (Source.ThrowOnError && !args.DoNotThrow)
                {
                    throw;
                }

                return(0);
            }

            Source.OnDelete(args);

            return(1);
        }
コード例 #4
0
        protected override int ExecuteDelete(IDictionary keys, IDictionary oldValues)
        {
            ActiveRecordDataSourceDeleteEventArgs args = new ActiveRecordDataSourceDeleteEventArgs();
            args.ModelType = BuildManager.GetType(Source.TypeName, false, true);

            IClassMetadata meta = ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(args.ModelType).GetClassMetadata(args.ModelType);
            if (!meta.HasIdentifierProperty)
                throw new ApplicationException("ActiveRecordDataSourceView requires a primary key for the delete method.");

            args.KeyProperty = meta.IdentifierPropertyName;
            args.KeyValue = keys[meta.IdentifierPropertyName];

            try
            {
                args.Entity = ActiveRecordMediator.FindByPrimaryKey(args.ModelType, args.KeyValue);            

                Source.OnBeforeDelete(args);

                if (args.Cancel)
                    return 0;
            
                ActiveRecordMediator.Delete(args.Entity);
            }
            catch (Exception e)
            {
                args.Exception = e;
                args.WasError = true;

                Source.OnDeleteError(args);

                if (Source.ThrowOnError && !args.DoNotThrow)
                    throw;

                return 0;
            }

            Source.OnDelete(args);

            return 1;
        }
コード例 #5
0
 public void OnDeleteError(ActiveRecordDataSourceDeleteEventArgs e)
 {
     if (DeleteError != null)
         DeleteError(this, e);
 }
コード例 #6
0
 public void OnBeforeDelete(ActiveRecordDataSourceDeleteEventArgs e)
 {
     if (BeforeDelete != null)
         BeforeDelete(this, e);
 }