コード例 #1
0
        public int AddPhone(string phoneName, int warehouseId)
        {
            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Creating phone");
            IPhone newPhone = productionFactory.CreatePhone(phoneName);

            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Looking for warehouse in repository");
            IWarehouse warehouse = warehouses.Find(warehouseId);

            if (null == warehouse)
            {
                return(-1);
            }

            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Supplying phones to warehouse");
            phoneSupplier.SupplyPhonesToWarehouse(newPhone, warehouse);
            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Updating warehouse in repository");
            warehouses.Update(warehouseId, warehouse);
            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Saving phone to repository");
            int phoneId = phones.Save(newPhone);

            return(phoneId);
        }