コード例 #1
0
        /* private bool AddWarehouseRecursive(WarehouseModel warehouse)
         * {
         *   try
         *   {
         *       bool isOK = true;
         *       if (ValidateWarehouseModel(warehouse))
         *       {
         *
         *           foreach (WarehouseModel wh in warehouse.NextHops)
         *           {
         *               wh.Parent = warehouse;
         *               isOK = isOK && AddWarehouseRecursive(wh);
         *           }
         *           foreach (TruckModel truck in warehouse.Trucks)
         *           {
         *               truck.Parent = warehouse;
         *               isOK = isOK && AddTruck(truck);
         *           }
         *
         *           if (isOK)
         *           {
         *
         *               var warehouseDAO = Mapper.Map<WarehouseModel, WarehouseDAO>(warehouse);
         *               _warehouseRepository.Create(warehouseDAO);
         *               _logger.Info("Warehouse added: " + warehouseDAO.Code);
         *           }
         *           return isOK;
         *       }
         *       return false;
         *   }
         *   catch (Exception ex)
         *   {
         *       throw new BLException("Error setting up warehouses (recursion)", ex);
         *   }
         *
         * }*/

        private bool AddTruck(TruckModel truckModel)
        {
            try
            {
                if (ValidateTruckModel(truckModel))
                {
                    var truckDAO = Mapper.Map <TruckModel, TruckDTO>(truckModel);
                    _truckRepository.Create(truckDAO);
                    _logger.Info("Truck added: " + truckDAO.Code + " [" + truckDAO.NumberPlate + "]");
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw new BLException("Error adding truck: " + ex.Message + ", Inner: " + ex.InnerException.Message, ex);
            }
        }