/// <summary> /// Create a new InventoryItem object. /// </summary> /// <param name="rowId">Initial value of the RowId property.</param> /// <param name="inventoryItemId">Initial value of the InventoryItemId property.</param> /// <param name="inventoryItemName">Initial value of the InventoryItemName property.</param> public static InventoryItem CreateInventoryItem(global::System.Int32 rowId, global::System.Guid inventoryItemId, global::System.String inventoryItemName) { InventoryItem inventoryItem = new InventoryItem(); inventoryItem.RowId = rowId; inventoryItem.InventoryItemId = inventoryItemId; inventoryItem.InventoryItemName = inventoryItemName; return inventoryItem; }
private static void SetInventoryItemReferencedEntities(InventoryItem entityItem, ref InventoryItemDto dtoItem) { if (entityItem.CategoryRowId.HasValue) { dtoItem.Category = entityItem.tblInventoryCategory.TranslateToDao(); } if (entityItem.LocationRowId.HasValue) { dtoItem.Location = entityItem.tblInventoryLocation.TranslateToDao(); } if (entityItem.PreferedSupplierRowId.HasValue) { dtoItem.PreferedSupplier = entityItem.tblInventorySupplier_1.TranslateToDao(); } }
/// <summary> /// Deprecated Method for adding a new object to the tblInventoryItem EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotblInventoryItem(InventoryItem inventoryItem) { base.AddObject("tblInventoryItem", inventoryItem); }
public bool Save(InventoryItemDto item) { if (item == null) { return false; } var entityItem = _entities.tblInventoryItem.Where(i => i.InventoryItemId == item.Id).SingleOrDefault(); if (entityItem == null) { entityItem = new InventoryItem { InventoryItemId = item.Id }; _entities.tblInventoryItem.AddObject(entityItem); } entityItem.ActualBalance = item.ActualBalance; entityItem.EstimatedBalance = item.EstimatedBalance; entityItem.ExpiringDate = item.ExpiringDate; entityItem.InventoryItemName = item.Name; entityItem.AverageOrderPrice = item.AverageOrderPrice.HasValue? (decimal)item.AverageOrderPrice: (decimal?) null ; entityItem.InventoryImage = item.Image; entityItem.LastOrderAmount = item.LastOrderAmount; if(item.Location != null) { var locationEntity = _entities.tblInventoryLocation.SingleOrDefault(l => l.LocationId == item.Location.Id); if (locationEntity != null) { entityItem.LocationRowId = locationEntity.RowId; } } if (item.Category != null) { var categoryEntity = _entities.tblInventoryCategory.SingleOrDefault(l => l.CategoryId == item.Category.Id); if (categoryEntity != null) { entityItem.CategoryRowId = categoryEntity.RowId; } } if(item.PreferedSupplier != null) { var supplierEntity = _entities.tblInventorySupplier.SingleOrDefault(l => l.SupplierId == item.PreferedSupplier.Id); if (supplierEntity != null) { entityItem.PreferedSupplierRowId = supplierEntity.RowId; } } _entities.SaveChanges(); if (!EntityCache.InventoryItems.Entities.Contains(item)) { EntityCache.InventoryItems.Add(item); } return true; }