public TruckModel GetTruckByCode(string code)
        {
            try
            {
                _logger.Info(string.Format("Getting truck by code {0}", code));
                var truckDAO   = _warehouseRepository.GetByCode(code);
                var truckModel = Mapper.Map <WarehouseDTO, TruckModel>(truckDAO);
                ValidateTruckModel(truckModel);

                return(truckModel);
            }
            catch (Exception ex)
            {
                throw new BLException("Error getting truck", ex);
            }
        }
Esempio n. 2
0
        public bool ReportHop(HopArrivalModel hopModel)
        {
            try
            {
                var truck     = _truckRepository.GetByCode(hopModel.Code);
                var warehouse = _warehouseRepository.GetByCode(hopModel.Code);
                var parcel    = _parcelRepository.GetByTrackingCode(hopModel.TrackingId);

                if (truck == null && warehouse == null)
                {
                    throw new Exception("Location code invalid");
                }
                if (parcel == null)
                {
                    throw new Exception("Parcel trackingId invalid");
                }

                _hopRepository.Create(Mapper.Map <HopArrivalModel, HopArrivalDTO>(hopModel));

                _logger.Info(string.Format("Parcel '{0}' has been scanned at LocationCode '{1}'. Timestamp: {2}", hopModel.TrackingId, hopModel.Code, hopModel.DateTime));
                return(true);
            }
            catch (Exception ex)
            {
                throw new BLException("BL error reporting hop: " + ex.Message, ex);
            }
        }
Esempio n. 3
0
 public Warehouse ExportWarehouseCode(string code)
 {
     try
     {
         logger.LogDebug("Exporting warehouse hierarchy");
         Data.Hop  dataWarehouse = wareHouseRepository.GetByCode(code);
         Warehouse warehouse     = this.mapper.Map <Warehouse>(dataWarehouse);
         return(warehouse);
     }
     catch (DataAccessLayerException e)
     {
         throw new BusinessLayerException("DAL Exception", e);
     }
 }