public async Task <IActionResult> Create([FromBody] CreateTripRequest tripRequest) { var trip = new Trip { Name = tripRequest.Name }; await _tripService.CreateTripAsync(trip); var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var locationUri = baseUrl + "/" + ApiRoutes.Trips.Get.Replace("{tripId}", trip.Id.ToString()); var response = new TripResponse { Id = trip.Id }; return(Created(locationUri, response)); }
public async Task <ActionResult> CreateAsync(CreateTripViewModel trip) { await _tripService.CreateTripAsync(trip); return(RedirectToAction("Index", new { customerId = trip.CustomerId })); }