/// <summary>Kreira novi objekt i postavlja default vrijednosti.</summary> public static CustomerAddress NewCustomerAddress(IActor creator) { var newObject = new CustomerAddress(-1) { NullCheckEnabled = false }; return newObject; }
/// <summary>Po potrebi konvertira entity u business objekt.</summary> public static CustomerAddress ConvertEntityToBusinessObject(CustomerAddressEntity entity) { CustomerAddress bizobj = entity as CustomerAddress; if (bizobj == null) bizobj = new CustomerAddress(entity); return bizobj; }
/// <summary>Initalizes new CustomerAddress child object. Not added to collection.</summary> public static CustomerAddress NewCustomerAddressChildren(Address parent) { var newItem = new CustomerAddress(); newItem.NullCheckEnabled = false; newItem.AddressID = ArrayUtil.NextNegativeId<CustomerAddressEntity>(parent.CustomerAddressChildren, (item) => (item.AddressID)); newItem.SetParent(newItem.Table.FK_AddressID, parent); return newItem; }
/// <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++) { CustomerAddressEntity entity = (CustomerAddressEntity)entities[i]; bool isBizObject = (entity is IBusinessObject); if (!isBizObject) entities[i] = new CustomerAddress(entity); } }
/// <summary>Saves collection CustomerAddressChildren to database.</summary> protected void DbSaveCustomerAddressChildren() { this.CustomerAddressChildren.SetParents(this.CustomerAddressChildren.Table.FK_AddressID, this, /*shared*/ true); DALHelper.GetDao<CustomerAddressEntity>(_ConnectionProvider).SaveCollection(this.CustomerAddressChildren); foreach (int item in this.oldCustomerAddressChildrenIDs) { if (!ArrayUtil.Exists<CustomerAddressEntity>(this.CustomerAddressChildren, x=>(int)x.GetPrimaryKeyValue()[0] == item)) { CustomerAddress bizItem = new CustomerAddress(item); bizItem.Delete(null); bizItem = null; } } SetOldCustomerAddressChildrenIDs(); }