public async Task <ActionResult> SaveFlightBookingAccommodationAsync(FlightBookingViewModel model) { var _booking = new TripBookingTransport(); if (model.FlightClass.ToLower().Contains("train")) { _booking.TransportType = "Train"; } else if (model.FlightClass.ToLower().Contains("flight")) { _booking.TransportType = "Flight"; } else if (model.FlightClass.ToLower().Contains("bus") || model.FlightClass.ToLower().Contains("coach")) { _booking.TransportType = "Bus"; } else if (model.FlightClass.ToLower().Contains("taxi")) { _booking.TransportType = "Taxi"; } else { _booking.TransportType = "Unknown"; } _booking.TripId = model.TripId; _booking.TripStepId = model.TripStepId; _booking.Id = model.TripBookingTransportId; _booking.Adults = model.Adults; _booking.BookingDate = model.FlightDate; _booking.BookingStatus = TransferBookingStatus.requested.ToString(); _booking.Kids = model.Kids; _booking.TransportFrom = model.From; _booking.TransportTo = model.To; _booking.TravelClass = model.FlightClass; _booking.TravellerNotes = model.TravellerNotes; var blError = await TripManager.SaveTripBookingTransportAsync(_booking); return(RedirectToAction("ViewTrip", new { @tripId = model.TripId })); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public static async Task <DomingoBlError> SaveTripBookingTransport(View_TripBookingTransport model) { try { if (model != null) { using (var context = new TravelogyDevEntities1()) { // add a new record if this is new if (model.Id == 0) { var _newBooking = new TripBookingTransport(); _newBooking.AdminNotes = model.AdminNotes; _newBooking.Adults = model.Adults; _newBooking.BookingDate = model.BookingDate; _newBooking.BookingStatus = model.BookingStatus; _newBooking.Currency = model.Currency; _newBooking.EstimatedCost = model.EstimatedCost; _newBooking.Kids = model.Kids; _newBooking.TransportFrom = model.TransportFrom; _newBooking.TransportTo = model.TransportTo; _newBooking.TransportType = model.TransportType; _newBooking.TravelClass = model.TravelClass; _newBooking.TransferDetails = model.TransferDetails; context.TripBookingTransports.Add(_newBooking); await context.SaveChangesAsync(); } // update existing record else { var _booking = context.TripBookingTransports.Find(model.Id); if (_booking != null) { _booking.AdminNotes = model.AdminNotes; _booking.Adults = model.Adults; if (model.BookingDate.HasValue) { _booking.BookingDate = model.BookingDate; } _booking.BookingStatus = model.BookingStatus; _booking.Currency = model.Currency; _booking.EstimatedCost = model.EstimatedCost; _booking.Kids = model.Kids; _booking.TransportFrom = model.TransportFrom; _booking.TransportTo = model.TransportTo; _booking.TransportType = model.TransportType; _booking.TravelClass = model.TravelClass; _booking.TransferDetails = model.TransferDetails; await context.SaveChangesAsync(); } } } } } catch (Exception ex) { return(new DomingoBlError() { ErrorCode = 100, ErrorMessage = ex.Message }); } return(new DomingoBlError() { ErrorCode = 0, ErrorMessage = "" }); }