public ActionQueryResult WritePassengerToDatabase(Passenger passenger, out int outputId) { outputId = -1; DatabaseTable passengerTargetTable = new DatabaseTable("passengers"); passengerTargetTable.AddAttribute("Id"); passengerTargetTable.AddAttribute("Title"); passengerTargetTable.AddAttribute("FirstName"); passengerTargetTable.AddAttribute("LastName"); passengerTargetTable.AddAttribute("PassportNumber"); ObjectRelationalMapper <Passenger> passengerMapper = new ObjectRelationalMapper <Passenger>(Config.DB_CONNECTION_STRING, null, passengerTargetTable); List <SqlParameter> passengerSqlParams = new List <SqlParameter>(); passengerSqlParams.Add(new SqlParameter("@Title", passenger.TitleString)); passengerSqlParams.Add(new SqlParameter("@FirstName", passenger.FirstName)); passengerSqlParams.Add(new SqlParameter("@LastName", passenger.LastName)); if (passenger.PassportId != null) { passengerSqlParams.Add(new SqlParameter("@PassportNumber", passenger.PassportId)); } ActionQueryResult passengerInsertResult = passengerMapper.Insert(passengerSqlParams.ToArray(), "Id", out outputId); return(passengerInsertResult); }
public ActionQueryResult WriteRawBookingToDatabase(int passengerId, int flightId, bool isWaiting, out int outputId) { DatabaseTable bookingTargetTable = new DatabaseTable("bookings"); bookingTargetTable.AddAttribute("Id"); bookingTargetTable.AddAttribute("PassengerId"); bookingTargetTable.AddAttribute("FlightId"); bookingTargetTable.AddAttribute("IsWaiting"); ObjectRelationalMapper <Booking> bookingMapper = new ObjectRelationalMapper <Booking>(Config.DB_CONNECTION_STRING, null, bookingTargetTable); SqlParameter[] sqlParams = new SqlParameter[] { new SqlParameter("@PassengerId", passengerId), new SqlParameter("@FlightId", flightId), new SqlParameter("@IsWaiting", isWaiting) }; ActionQueryResult bookingQueryResult = bookingMapper.Insert(sqlParams, "Id", out outputId); return(bookingQueryResult); }
public ActionQueryResult WriteSeatToDatabase(SeatNumber seat, int passengerId, int flightId) { DatabaseTable seatsTable = new DatabaseTable("seats"); seatsTable.AddAttribute("PosX"); seatsTable.AddAttribute("PosY"); seatsTable.AddAttribute("Id"); seatsTable.AddAttribute("FlightId"); seatsTable.AddAttribute("PassengerId"); ObjectRelationalMapper <Passenger> seatMapper = new ObjectRelationalMapper <Passenger>(Config.DB_CONNECTION_STRING, null, seatsTable); ActionQueryResult seatQueryResult = seatMapper.Insert(new SqlParameter[] { new SqlParameter("@PosX", seat.X), new SqlParameter("@PosY", seat.Y), new SqlParameter("@FlightId", flightId), new SqlParameter("@PassengerId", passengerId) }); return(seatQueryResult); }
public ActionQueryResult WriteBaggageToDatabase(Baggage baggage, int passengerId) { DatabaseTable baggageTargetTable = new DatabaseTable("baggage"); baggageTargetTable.AddAttribute("Id"); baggageTargetTable.AddAttribute("FlightId"); baggageTargetTable.AddAttribute("PassengerId"); baggageTargetTable.AddAttribute("Weight"); baggageTargetTable.AddAttribute("Fee"); ObjectRelationalMapper <Baggage> baggageMapper = new ObjectRelationalMapper <Baggage>(Config.DB_CONNECTION_STRING, null, baggageTargetTable); SqlParameter[] sqlParams = new SqlParameter[] { new SqlParameter("@FlightId", baggage.FlightId), // TODO: FlightId fehlt! Muss vor Übergabe zugewiesen werden! new SqlParameter("@PassengerId", passengerId), new SqlParameter("@Weight", baggage.Weight), new SqlParameter("@Fee", baggage.Fee) }; ActionQueryResult baggageQueryResult = baggageMapper.Insert(sqlParams); return(baggageQueryResult); }