public DataTable BookTicket(string bookingId)
        {
            try
            {
                TGTravelServiceClient o = new TGTravelServiceClient();
                o.Open();
                DataTable data = new DataTable();
                data.Columns.Add("bookingId");
                data.Columns.Add("extraSeatInfo");
                data.Columns.Add("seatNbr");
                data.Columns.Add("travelsPhoneNbr");
                data.Columns.Add("cancellationDescList");
                data.Columns.Add("Status");
                BookingDetails booking = o.bookTicket(UserId, Password, bookingId);

                Array cancelarr = booking.extraSeatInfoList;
                foreach (ExtraSeatInfoDTO Cdesc in cancelarr)
                {
                    DataRow row = data.NewRow();
                    row["bookingId"] = bookingId;
                    row["extraSeatInfo"] = Cdesc.extraSeatInfo;
                    row["seatNbr"] = Cdesc.seatNbr;
                    row["travelsPhoneNbr"] = booking.travelsPhoneNbr;
                    row["Status"] = booking.status.message.ToString();
                    Array ac = booking.cancellationDescList;
                    row["cancellationDescList"] = ac.ToString();
                    data.Rows.Add(row);
                }
                o.Close();
                return data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        /// <summary>
        /// Method for booking a ticket using userid,password,bookingid
        /// </summary>
        /// <param name="bookingId"></param>
        /// <returns></returns>
        public BookSeatsResponse BookTicket(String bookingId, String URL, String ConsumerKey, String ConsumerSecret)
        {
            BookSeatsResponse objBookSeatsResponse = new BookSeatsResponse();
            try
            {
                client = new TGTravelServiceClient("TGSWS", URL);
                BookingDetails response = client.bookTicket(ConsumerKey, ConsumerSecret, bookingId);

                string strTicketGooseBookingResponse = JsonConvert.SerializeObject(response);

                DataSet ds = convertJsonStringToDataSet(strTicketGooseBookingResponse);

                if (ds != null && ds.Tables["status"] != null)
                {
                    if (ds.Tables["status"].Rows[0]["code"].ToString().Trim() == "200"
                        && ds.Tables["status"].Rows[0]["message"].ToString().Trim().ToLower() == "success")
                    {
                        objBookSeatsResponse.Status = "SUCCESS";
                        foreach (DataRow item in ds.Tables["extraSeatInfoList"].Rows)
                        {
                            objBookSeatsResponse.OperatorPNR = item["extraSeatInfo"].ToString();
                                //(objBookSeatsResponse.OperatorPNR == "") ?
                                    //                            item["extraSeatInfo"].ToString() :
                                   //                             objBookSeatsResponse.OperatorPNR + "," + item["extraSeatInfo"].ToString();
                            objBookSeatsResponse.OperaterNo = item["extraSeatInfo"].ToString();
                            objBookSeatsResponse.extraseatinfo = item["extraSeatInfo"].ToString();
                        }
                    }
                    else
                    {
                        objBookSeatsResponse.Status = "FAIL"; objBookSeatsResponse.Message = ds.Tables["status"].Rows[0]["message"].ToString().Trim();
                    }
                }
                else
                    objBookSeatsResponse.Status = "FAIL";

                objBookSeatsResponse.APIPNR = (objBookSeatsResponse.Status == "SUCCESS") ? bookingId : "";
            }
            catch (Exception ex)
            {
                // to do
            }
            return objBookSeatsResponse;
        }