public void CreateHop_Succeeded() { Hop hop = new Hop() { Code = "ABCDEF123" }; string code = _dal.Create(hop); Assert.AreEqual("ABCDEF123", code); }
public void ImportHierarchy(Warehouse _wh) { var validator = new WarehouseValidation(); var checkWarehouse = validator.Validate(_wh); if (!checkWarehouse.IsValid) { throw new Exception("Import Warehouse Tree failed in BL"); } var whDAL = _mapper.Map <DAL.Warehouse>(_wh); try { _sqlRepo.ClearDatabase(); _sqlRepo.Create(whDAL); } catch (DAL.DALException exc) { _logger.LogError(exc.ToString()); throw new BLException($"{exc.GetType()} Exception in {System.Reflection.MethodBase.GetCurrentMethod().Name}", exc); } catch (Exception exc) { _logger.LogError(exc.ToString()); throw new BLException($"{exc.GetType()} Exception in {System.Reflection.MethodBase.GetCurrentMethod().Name}", exc); } }
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); } }