public async Task <IActionResult> InsertPassanger([FromBody] Passengers passengers) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Passengers.Add(passengers); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPassengers", new { id = passengers.IdPassageiro }, passengers)); }
public async Task <IActionResult> InsertPassangerToAirplane([FromBody] Passengers passengers) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Passengers.Add(passengers); await _context.SaveChangesAsync(); var passengerID = await _context.Passengers .Include(i => i.IdAviao) .FirstOrDefaultAsync(i => i.IdAviao == passengers.IdAviao); return(CreatedAtAction("GetPassengers", new { id = passengers.IdPassageiro }, passengerID)); }