public async Task <IActionResult> Create([FromBody] BookingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var flight = await _repository.GetByIdAsync(model.FlightId); if (flight == null) { return(NotFound()); } var booking = model.ToDomain(); var result = flight.Book(booking); if (!result.IsSuccess) { return(result.Error.ToResult()); } var updateResult = await _repository.UpdateAsync(flight); if (!updateResult.IsSuccess) { return(updateResult.Error.ToResult()); } var url = Url.RouteUrl("GetBookingById", new { id = booking.Id }); var projection = await _view.GetByIdAsync(booking.Id); return(Created(url, projection)); }