/// <summary> /// Добавить объект инвентаризации /// </summary> /// <param name="ObjectInventoryDTO">Бизнес-модель объекта инвентаризации</param> public void Create(ObjectInventoryDTO ObjectInventoryDTO) { ObjectType objectType = Database.ObjeсtTypes.Get(ObjectInventoryDTO.ObjectTypeId); ObjectInventory objectInventory = new ObjectInventory { Name = ObjectInventoryDTO.Name, Count = ObjectInventoryDTO.Count, Barcode = ObjectInventoryDTO.Barcode, Type = objectType }; Database.ObjectInventories.Create(objectInventory); Database.Save(); }
internal Building(string name, BuildingType atype, BuildingRole arole) { Name = name; type = atype; role = arole; switch (arole) { case BuildingRole.Production: availableProducts = new ObjectInventory <string, int>(); Ready = DateTime.UtcNow; break; case BuildingRole.Stats: stats = new SandBoxStats(); break; } }
public void AddItemToUnit(ItemInformation item, UnitBaseBehaviourComponent unitHolder) { string tmp = unitHolder.myStats.id; int idx = 0; ObjectInventory check = unitInventory.Find(x => x.unitOwner == unitHolder); if (check != null) { if (unitInventory.Contains(check)) { idx = unitInventory.IndexOf(check); unitInventory[idx].AddItem(item); } } else { check = new ObjectInventory(); unitInventory.Add(check); idx = unitInventory.IndexOf(check); unitInventory[idx].AddItem(item); } unitInventory[idx].unitOwner = unitHolder; }