public string AddParcel(IO.Swagger.Models.Parcel serviceParcel) { try { if (serviceParcel == null) { throw new BlException("Received Service Parcel was null"); } var blParcel = _mapper.Map <Entities.Parcel>(serviceParcel); if (blParcel != null) { string validationResults = ValidatePreAddedParcel(blParcel); if (validationResults != "") { _logger.LogError(validationResults); throw new BlException("Given parcel is not valid", new ArgumentException("Given Parcel is not valid")); } } var dalParcel = _mapper.Map <DataAccess.Entities.Parcel>(blParcel); dalParcel.TrackingInformation = GenerateTrackingInformation(dalParcel); dalParcel.TrackingNumber = GenerateTrackingNumber(8); _parcelRepo.Create(dalParcel); return(dalParcel.TrackingNumber); } catch (Exception ex) { _logger.LogError("Could not add parcel", ex); throw new BlException("Could not add parcel", ex); } }
private void CreateTestData() { validSwagRec = new IO.Swagger.Models.Recipient("Tobias", "Test", "Horvathgasse 2", "A-1160", "Wien"); validSwagParcel = new IO.Swagger.Models.Parcel(1.5f, validSwagRec); validBLRec = new Entities.Recipient("Tobias", "Test", "Horvathgasse 2", "A-1160", "Wien"); validBLParcel = new Entities.Parcel(1.5f, validBLRec); invalidBLRec = new Entities.Recipient("Tobias", "Test", "Horvathgasse 2", "1160", "Wien"); invalidBLParcel = new Entities.Parcel(1.5f, invalidBLRec); validDALRec = new DataAccess.Entities.Recipient("Tobias", "Test", "Horvathgasse 2", "A-1160", "Wien"); validDALParcel = new DataAccess.Entities.Parcel(1.5f, validDALRec, 1); validSARecipient = new ServiceAgents.DTOs.Recipient("Tobias", "Test", "Horvathgasse 2", "A-1160", "Wien"); validBLLocation = new Entities.Location { Lat = 48.2057943, Lng = 16.3066716 }; }