public DataTable BlockSeatsForBooking(string scheduleId, string TravelDate, string FromStationId, string ToStationId, string boardingPointId, string emailId, string mobileNbr, string address, PassengerDetailDTO[] PassengerDetailDTO) { try { TGTravelServiceClient o = new TGTravelServiceClient(); o.Open(); BlockedSeatsForBookingDetails BlockSeatsBooking = o.blockSeatsForBooking(UserId, Password, scheduleId, TravelDate, FromStationId, ToStationId, boardingPointId, emailId, mobileNbr, address, PassengerDetailDTO); DataTable data = new DataTable(); data.Columns.Add("BookingId"); data.Columns.Add("expireTime"); data.Columns.Add("cancellationDescList"); if (BlockSeatsBooking.status.message.ToString() == "Success") { foreach (var canceldesc in BlockSeatsBooking.cancellationDescList) { DataRow row = data.NewRow(); row["BookingId"] = BlockSeatsBooking.bookingId; row["expireTime"] = BlockSeatsBooking.expireTime; row["cancellationDescList"] = canceldesc.ToString(); data.Rows.Add(row); } } o.Close(); return data; } catch (Exception ex) { throw ex; } }
/// <summary> /// Method for blocking seats /// </summary> /// <returns></returns> public BlockSeatsResponse blockSeatsForBooking(String scheduleId, String travelDate, String fromStationId, String toStationId, String boardingPointId, String emailId, String mobileNbr, String address, String URL, String ConsumerKey, String ConsumerSecret, int noOfSeats, String seatNo, String title, String name, String age, String sex) { BlockSeatsResponse objBlockSeatsResponse = new BlockSeatsResponse(); try { travelDate = travelDate.Replace('-', '/'); String[] seatNoArray = seatNo.Split(','); String[] titleArray = title.Split(','); String[] nameArray = name.Split(','); String[] ageArray = age.Split(','); String[] sexArray = sex.Split(','); client = new TGTravelServiceClient("TGSWS", URL); PassengerDetailDTO[] PassengerDetailDT = new PassengerDetailDTO[noOfSeats]; for (int i = 0; i < noOfSeats; i++) { PassengerDetailDTO PassengerDetailDTO1 = new PassengerDetailDTO(); PassengerDetailDTO1.age = ageArray[i].ToString(); PassengerDetailDTO1.name = nameArray[i].ToString(); PassengerDetailDTO1.seatNbr = seatNoArray[i].ToString(); PassengerDetailDTO1.sex = sexArray[i].ToString(); PassengerDetailDT[i] = PassengerDetailDTO1; } BlockedSeatsForBookingDetails response = client.blockSeatsForBooking(ConsumerKey, ConsumerSecret, scheduleId , travelDate, fromStationId, toStationId, boardingPointId, emailId, mobileNbr, address, PassengerDetailDT); DataSet ds = convertJsonStringToDataSet(JsonConvert.SerializeObject(response)); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables["status"].Rows[0]["code"].ToString().Trim().ToLower() == "200") { if (ds.Tables[0].Columns.Contains("bookingId")) { objBlockSeatsResponse.BookingID = ds.Tables[0].Rows[0]["bookingId"].ToString(); objBlockSeatsResponse.Status = "SUCCESS"; } } else { objBlockSeatsResponse.Status = "FAIL"; objBlockSeatsResponse.Message = ds.Tables["status"].Rows[0]["message"].ToString(); } } } else { objBlockSeatsResponse.Status = "FAIL"; } } catch (Exception ex) { // to do } return objBlockSeatsResponse; }