/// <summary>Initalizes new ProductCategory child object. Not added to collection.</summary> public static ProductCategory NewProductCategoryChildren(ProductCategory parent) { var newItem = new ProductCategory(); newItem.NullCheckEnabled = false; newItem.ProductCategoryID = ArrayUtil.NextNegativeId<ProductCategoryEntity>(parent.ProductCategoryChildren, (item) => (item.ProductCategoryID)); newItem.SetParent(newItem.Table.FK_ParentProductCategoryID, parent); return newItem; }
/// <summary>Saves collection ProductCategoryChildren to database.</summary> protected void DbSaveProductCategoryChildren() { this.ProductCategoryChildren.SetParents(this.ProductCategoryChildren.Table.FK_ParentProductCategoryID, this, /*shared*/ true); DALHelper.GetDao<ProductCategoryEntity>(_ConnectionProvider).SaveCollection(this.ProductCategoryChildren); foreach (int item in this.oldProductCategoryChildrenIDs) { if (!ArrayUtil.Exists<ProductCategoryEntity>(this.ProductCategoryChildren, x=>(int)x.GetPrimaryKeyValue()[0] == item)) { ProductCategory bizItem = new ProductCategory(item); bizItem.Delete(null); bizItem = null; } } SetOldProductCategoryChildrenIDs(); }
/// <summary>Po potrebi konvertira entity u business objekt.</summary> public static ProductCategory ConvertEntityToBusinessObject(ProductCategoryEntity entity) { ProductCategory bizobj = entity as ProductCategory; if (bizobj == null) bizobj = new ProductCategory(entity); return bizobj; }
/// <summary>Kreira novi objekt i postavlja default vrijednosti.</summary> public static ProductCategory NewProductCategory(IActor creator) { var newObject = new ProductCategory(-1) { NullCheckEnabled = false }; return newObject; }
/// <summary>Non-business object elemente kolekcije konvertira u business objekte.</summary> public static void ConvertEntitiesToBusinessObjects(IEntityCollection entities) { for (int i = 0; i < entities.Count; i++) { ProductCategoryEntity entity = (ProductCategoryEntity)entities[i]; bool isBizObject = (entity is IBusinessObject); if (!isBizObject) entities[i] = new ProductCategory(entity); } }