public async Task <IActionResult> Post([FromBody] FlightDTO value) { var validationResult = await _flightModelValidator.ValidateAsync(value); if (!validationResult.IsValid) { throw new BadRequestException(validationResult.Errors); } var entity = await _flightService.CreateAsync(value); return(Json(entity)); }
public async Task <IActionResult> CreateFlight(Flight flight) { try { await service.CreateAsync(flight); return(Ok("Create success")); } catch (Exception ex) { return(await Task.FromResult(new ObjectResult(ex))); } }
public async Task <IActionResult> CreateFlightAsync(Flight flight) { try { var result = await service.CreateAsync(flight); if (result == null) { return(new InternalServerErrorResult()); } return(Ok(result)); } catch (Exception ex) { return(new ExceptionResult(ex, true)); } }