public async Task <ActionResult <PassengerM> > PostPassengerM(PassengerM passengerM) { var passenger = new Passenger(); if (passengerM == null) { return(NotFound()); } else { passenger.GivenName = passengerM.GivenName; passenger.Surname = passengerM.Surname; } _context.PassengerSet.Add(passenger); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (BookingExists(passenger.PersonID)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetPassenger", new { id = passenger.PersonID }, passenger)); }
public async Task <ActionResult <IEnumerable <PassengerM> > > GetBookingSet() { var passengerList = await _context.PassengerSet.ToListAsync(); List <PassengerM> passengerListTmp = new List <PassengerM>(); foreach (Passenger p in passengerList) { PassengerM pM = new PassengerM(); pM.PersonID = p.PersonID; pM.GivenName = p.GivenName; pM.Surname = p.Surname; passengerListTmp.Add(pM); } return(passengerListTmp); }
public async Task <ActionResult <PassengerM> > GetPassenger(int id) { var passenger = await _context.PassengerSet.FindAsync(id); var passengerM = new PassengerM(); if (passenger == null) { return(NotFound()); } else { passengerM.PersonID = passenger.PersonID; passengerM.GivenName = passenger.GivenName; passengerM.Surname = passenger.Surname; } return(passengerM); }