public void Setup() { _sut = new TrainingProviderClosestLocationsViewModelMapper(); _resultsItemToMap = new GetClosestLocationsResponse() { ProviderName = "Test Provider", Results = new SearchResult <CloseTrainingLocation>() { Total = 10, Hits = new List <CloseTrainingLocation>() { new CloseTrainingLocation { Distance = 1.23, LocationId = 111, LocationName = "Location 1 Name", Address = new Core.Domain.Model.Address { Address1 = "Address 1", Address2 = "Address 2", Town = "Town", County = "County", Postcode = "AB1 2AS" } }, new CloseTrainingLocation { Distance = 2.45, LocationId = 222, LocationName = "Location 2 Name", Address = new Core.Domain.Model.Address { Address1 = "Address 1", Address2 = "Address 2", Town = "Town", County = "County", Postcode = "AB1 2AS" } } }, } }; }
public ClosestLocationsViewModel Map(string apprenticeshipId, int ukprn, int locationId, string postcode, GetClosestLocationsResponse source) { var model = new ClosestLocationsViewModel { ApprenticeshipId = apprenticeshipId, ProviderName = source.ProviderName, Ukprn = ukprn, LocationId = locationId, PostCode = postcode, Locations = source.Results.Hits.Select(x => new CloseLocationViewModel { LocationId = x.LocationId, Distance = x.Distance, PostCode = x.Address.Postcode, AddressWithoutPostCode = x.Address.GetCommaDelimitedAddress() }).ToList() }; return(model); }