public static BookingWSPage getBookingPage(string tenantName, int fromIdx, int count) { try { using (BookingServicePortTypeClient client = getWSClient()) { BookingPage bp = client.getBookingPageByTenant(tenantName, fromIdx, count); List<BookingWS> bookings = new List<BookingWS>(); if (bp != null && bp.bookings != null && bp.bookings.Length > 0) { List<string> bkgIds = new List<string>(bp.bookings.Length); foreach (var b in bp.bookings) { bkgIds.Add(b.id); } IDictionary<string, PaymentWS> payments = GetPayments(bkgIds); foreach (var b in bp.bookings) { PaymentWS p; if (!payments.TryGetValue(b.id, out p)) { p = null; } BookingWS bws = new BookingWS(b.id, (DateTime)b.bookingDate, b.userName, b.journeyId, b.journeyName, p); bookings.Add(bws); } } BookingWSPage ret = new BookingWSPage(bookings, bp.fromIdx, bp.count, bp.total); return ret; } } catch (Exception e) { log.Error("can't retrieve Booking page", e); throw new FaultException(e.GetType().Name + " when retrieving booking data. Message: " + e.Message); } }
public BookingWSPage getBookingPage(string tenantName, int fromIdx, int count) { FinanceServiceDefault.BookingWSPage wsPage = client.getBookingPage(tenantName, fromIdx, count); List<BookingWS> bookings = new List<BookingWS>(); foreach (FinanceServiceDefault.BookingWS bkg in wsPage.Bookings) { PaymentWS payment = null; if (bkg.Payment != null) { FinanceServiceDefault.PaymentWS pay = bkg.Payment; CreditCardWS creditCard = new CreditCardWS(pay.CreditCard.CCNumber, pay.CreditCard.User, pay.CreditCard.ValidThrough); payment = new PaymentWS(pay.BookingId, creditCard, pay.Amount, bkg.Payment.Date); } bookings.Add(new BookingWS(bkg.BookingId, bkg.BookingDate, bkg.UserName, bkg.JourneyId, bkg.JourneyName, payment)); } BookingWSPage retPage = new BookingWSPage(bookings, wsPage.FromIdx, wsPage.Count, wsPage.Total); return retPage; }