public void Add(SupplyInventoryModel model) { using (var uow = new UnitOfWork(new DataContext())) { var supplyType = uow.SupplyTypes.GetIncludeSupplyClass(model.SupplyTypeID); if (supplyType.SupplyClass.Description == "Raw Milk") { throw new ApplicationException("Values for this group (Raw Milk) will automatically generated by milk collection form and production form!"); } // use to avoid multiple record of supply type per month var supplyInv = uow.SupplyInventories.GetByMonth(model.Date, supplyTypeID: model.SupplyTypeID); if (supplyInv != null) { throw new ApplicationException("Record for selected Supply was already created!"); } var obj = new SupplyInventory(); obj.CreateDateTime = DateTime.Now; obj.ActualDate = model.Date; obj.PurchaseQuantity = model.PurchaseQuantity; obj.SupplyTypeID = model.SupplyTypeID; obj.WithdrawQuantity = 0; uow.SupplyInventories.Add(obj); uow.Complete(); model.ID = obj.SupplyInventoryID; } }
void Start() { finishedSound = gameObject.GetComponent <AudioSource>(); enemySupplyScript = GameObject.FindGameObjectWithTag("EnemySupplyInventory").GetComponent <SupplyInventory>(); GameObject[] enemyBuildings = GameObject.FindGameObjectsWithTag("EnemyBuilding"); foreach (GameObject building in enemyBuildings) { if (building != gameObject && building.GetComponent <FactoryBuildEnemy>()) //if the building isn't the current building, but has a script for enemy construction, add that script to the list { enemyFactoryScripts.Add(building.GetComponent <FactoryBuildEnemy>()); } } }
void Start() { MySupplyInventory = GameObject.FindGameObjectWithTag(MyTeam + "SupplyInventory").GetComponent <SupplyInventory>(); }