public void OnDeleteError(ActiveRecordDataSourceDeleteEventArgs e) { if (DeleteError != null) { DeleteError(this, e); } }
public void OnBeforeDelete(ActiveRecordDataSourceDeleteEventArgs e) { if (BeforeDelete != null) { BeforeDelete(this, e); } }
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); }
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; }
public void OnDeleteError(ActiveRecordDataSourceDeleteEventArgs e) { if (DeleteError != null) DeleteError(this, e); }
public void OnBeforeDelete(ActiveRecordDataSourceDeleteEventArgs e) { if (BeforeDelete != null) BeforeDelete(this, e); }