public IActionResult CreateTrip([FromBody] TripForCreationDto newTrip) { if (newTrip == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(new UnprocessableEntityObjectResult(ModelState)); } var tripEntity = CustomMapper.MapTripDtoToTrip(newTrip); TripsRepository.AddTrip(tripEntity); if (!TripsRepository.Save()) { throw new System.Exception("Creating an wish trip failed on save."); } // var newTripToReturn = CustomMapper.MapTripTripDto(tripEntity); return(CreatedAtRoute("GetTrip", new { id = tripEntity.Id }, null )); }
Trip IConverter.MapTripDtoToTrip(TripForCreationDto value) { Trip nuevoViaje = new Trip() { DateVisited = value.VisitedDate, IdCountry = value.IdPais, TravelerId = 10 }; return(nuevoViaje); }