public void CanConvertDtoToLocation() { var locationDto = new LocationDto { Latitude = 55.6739062, Longitude = 12.5556993 }; var location = DtoMapper.ConvertDtoToLocation(locationDto); Assert.Equal(locationDto.Latitude, location.Latitude); Assert.Equal(locationDto.Longitude, location.Longitude); }
public IActionResult AddLocation(string tripIdentifier, [FromBody] LocationDto locationDto) { if (!IsValidTripIdentifier(tripIdentifier)) { return(BadRequest(tripIdentifier)); } if (!ModelState.IsValid) { return(BadRequest(locationDto)); } var trip = _tripRepository.FindTrip(tripIdentifier); if (trip == null) { return(NotFound()); } trip.Locations.Add(DtoMapper.ConvertDtoToLocation(locationDto)); _tripRepository.Update(trip); return(new NoContentResult()); }