public  void postXMLData1()
        {
            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
            try
            {
            
                string uri = AppStatic.WebServiceBaseURL;  // some xml string
                Uri _url = new Uri(uri, UriKind.RelativeOrAbsolute);
                GetAvailableServicesRequest _objAGR = new GetAvailableServicesRequest();
                _objAGR.franchUserID = AppStatic.franchUserID;
                _objAGR.password = AppStatic.password;
                _objAGR.userID = AppStatic.userID;
                _objAGR.userKey = AppStatic.userKey;
                _objAGR.userName = AppStatic.userName;
                _objAGR.userRole = AppStatic.userRole;
                _objAGR.userStatus = AppStatic.userStatus;
                _objAGR.userType = AppStatic.userType;
                _objAGR.placeNameFrom = txtBFromLocationT.Text;
                _objAGR.placeNameTo = txtBToLocationT.Text;
                _objAGR.placeIDFrom = txtBFromID.Text;
                _objAGR.placeIDto = txtBToID.Text;
                _objAGR.placeCodeFrom = txtBFromCode.Text;
                _objAGR.placeCodeTo = txtBToCode.Text;
                string d = txtBDateTab.Text;
                System.DateTime dt = System.DateTime.ParseExact(d, "dd MMM yyyy", CultureInfo.InvariantCulture);
                string Date = dt.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                _objAGR.journeyDate = Date;

                xmlUtility listings = new xmlUtility();
                XDocument element = listings.getservice(_objAGR);
                string stringXml = element.ToString();
                var httpClient = new Windows.Web.Http.HttpClient();
                var info = AppStatic.WebServiceAuthentication;
                var token = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(info));
                httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Basic", token);
                httpClient.DefaultRequestHeaders.Add("SOAPAction", "");
                Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, _url);
                httpRequestMessage.Headers.UserAgent.TryParseAdd("Mozilla/4.0");
                IHttpContent content = new HttpStringContent(stringXml, Windows.Storage.Streams.UnicodeEncoding.Utf8);
                httpRequestMessage.Content = content;
                Windows.Web.Http.HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage);
                string strXmlReturned = await httpResponseMessage.Content.ReadAsStringAsync();
                XmlDocument xDoc = new XmlDocument();
                XDocument loadedData = XDocument.Parse(strXmlReturned);
                XDocument element1 = listings.getAvailableServicelayout(_objAGR);
                string stringXml1 = element1.ToString();

                byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(stringXml1.ToString());
                StorageFile file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("HistoryTest1.xml", CreationCollisionOption.OpenIfExists);
                String historyTestContent = await FileIO.ReadTextAsync(file);
                using (var stream = await file.OpenStreamForWriteAsync())
                {
                    stream.Seek(0, SeekOrigin.End);
                    stream.Write(fileBytes, 0, fileBytes.Length);
                }

                List<XElement> _list = (from t1 in loadedData.Descendants("wsResponse") select t1).ToList();
                List<PlaceList> seatsList = new List<PlaceList>();
                string _msg = "";
                if (_list != null)
                {
                    foreach (XElement _elemet in _list)
                    {
                        PlaceList _obj = new PlaceList();
                        _obj.message = _elemet.Element("message").Value.ToString();
                        seatsList.Add(_obj);
                    }
                    _msg = seatsList.FirstOrDefault().message.ToString();
                }                
                if (_msg != "FAILURE")
                {
                    var sdata = loadedData.Descendants("service").
                    Select(x => new GetAvailableService
                    {
                        arrivalDate = x.Element("arrivalDate").Value,
                        arrivalTime = x.Element("arrivalTime").Value,
                        classID = x.Element("classID").Value,
                        classLayoutID = x.Element("classLayoutID").Value,
                        className = x.Element("className").Value,
                        corpCode = x.Element("corpCode").Value,
                        departureTime = x.Element("departureTime").Value,
                        destination = x.Element("destination").Value,
                        fare = x.Element("fare").Value,
                        journeyDate = x.Element("journeyDate").Value,
                        journeyHours = x.Element("journeyHours").Value,
                        maxSeatsAllowed = x.Element("maxSeatsAllowed").Value,
                        origin = x.Element("origin").Value,
                        placeIDFrom = x.Element("biFromPlace").Element("placeID").Value,
                        placeIDto = x.Element("biToPlace").Element("placeID").Value,
                        refundStatus = x.Element("refundStatus").Value,
                        routeNo = x.Element("routeNo").Value,
                        seatsAvailable = x.Element("seatsAvailable").Value,
                        seatStatus = x.Element("seatStatus").Value,
                        serviceID = x.Element("serviceID").Value,
                        startPoint = x.Element("startPoint").Value,
                        studID = x.Element("stuID").Value,
                        tripCode = x.Element("tripCode").Value,
                        viaPlaces = x.Element("viaPlaces").Value
                    });
                    foreach (var item in sdata)
                    {
                        GetAvailableService gas = new GetAvailableService();
                        gas.arrivalDate = item.arrivalDate;
                        gas.arrivalTime = item.arrivalTime;
                        gas.classID = item.classID;
                        gas.classLayoutID = item.classLayoutID;
                        gas.className = item.className;
                        gas.corpCode = item.corpCode;
                        gas.departureTime = item.departureTime;
                        gas.destination = item.destination;
                        gas.fare = item.fare;
                        gas.journeyDate = item.journeyDate;
                        gas.journeyHours = item.journeyHours;
                        gas.maxSeatsAllowed = item.maxSeatsAllowed;
                        gas.origin = item.origin;
                        gas.placeIDFrom = item.placeIDFrom;
                        gas.placeIDto = item.placeIDto;
                        gas.refundStatus = item.refundStatus;
                        gas.routeNo = item.routeNo;
                        gas.seatsAvailable = item.seatsAvailable;
                        gas.seatStatus = item.seatStatus;
                        gas.serviceID = item.serviceID;
                        gas.startPoint = item.startPoint;
                        gas.studID = item.studID;
                        gas.tripCode = item.tripCode;
                        gas.viaPlaces = item.viaPlaces;
                        availableservice.Add(gas);
                    }
                    ListMenuItems.ItemsSource = sdata;

                    string MaxPriceresult = sdata.OrderByDescending(x => x.fare).Select(x => x.fare).FirstOrDefault().ToString();
                    if (MaxPriceresult != null)
                    {
                        txtBMaxPriceCurrent.Text = MaxPriceresult;
                        txtBMaxPrice.Text = MaxPriceresult;
                        maxPrice = Convert.ToInt32(MaxPriceresult);
                        MaxPrice = Convert.ToInt32(MaxPriceresult);
                        Thumb2PositionPrice = Convert.ToInt32(MaxPriceresult);
                    }

                    string MinPriceresult = sdata.OrderBy(x => x.fare).Select(x => x.fare).FirstOrDefault().ToString();
                    if (MinPriceresult != null)
                    {
                        txtBMinPrice.Text = MinPriceresult;
                        txtBMinPriceCurrent.Text = MinPriceresult;
                        minPrice = Convert.ToInt32(MinPriceresult);
                        MinPrice = Convert.ToInt32(MinPriceresult);
                        Thumb1PositionPrice = Convert.ToInt32(MinPriceresult);
                    }
                    ListMenuItemsFilterCorp.ItemsSource = sdata.Select(x => x.corpCode).Distinct().ToList();
                    ListMenuItemsFilterBusType.ItemsSource = sdata.Select(x => x.className).Distinct().ToList();

                    FilterFunVisible();
                }
                else
                {
                    FilterFunCollapsed();

                }
             
            }
            catch (Exception ex)
            {
                LoaderPop.Visibility = Visibility.Collapsed;
                ErrorpopUp.Visibility = Visibility.Visible;               
                ExceptionLog obj = new ExceptionLog();
                Error objError = new Error();
                objError.ErrorEx = ex.Message;
                obj.CreateLogFile(objError);
            }
            }).AsTask();
        }
        public  void postXMLData1(GetAvailableService Get)
        {
            try
            {
                 var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
             {
                string uri = AppStatic.WebServiceBaseURL;
                Uri _url = new Uri(uri, UriKind.RelativeOrAbsolute);
                GetSeatlayoutRequest _objSLR = new GetSeatlayoutRequest();
                _objSLR.franchUserID = AppStatic.franchUserID;
                _objSLR.password = AppStatic.password;
                _objSLR.userID = AppStatic.userID;
                _objSLR.userKey = AppStatic.userKey;
                _objSLR.userName = AppStatic.userName;
                _objSLR.userRole = AppStatic.userRole;
                _objSLR.userStatus = AppStatic.userStatus;
                _objSLR.userType = AppStatic.userType;
                _objSLR.placeIDFrom = Get.placeIDFrom;
                _objSLR.placeCodeFrom = Get.placeCodeFrom;
                _objSLR.placeNameFrom = Get.placeNameFrom;
                _objSLR.placeIDto = Get.placeIDto;
                _objSLR.placeCodeTo = Get.placeCodeTo;
                _objSLR.placeNameTo = Get.placeNameTo;
                _objSLR.journeyDate = Get.journeyDate;
                _objSLR.classID = Get.classID;
                _objSLR.classLayoutID = Get.classLayoutID;
                _objSLR.serviceID = Get.serviceID;               
                _objSLR.placeCodestuFromPlace = txthplaceCodeStatusFrm.Text;
                _objSLR.placeCodestuToPlace = txthplaceCodeStatusTo.Text;
                _objSLR.placeIDstuFromPlace = txthplaceIDStatusFrm.Text;
                _objSLR.placeIDstuToPlace = txthplaceIDStatusTo.Text;
                _objSLR.placeNamestuFromPlace = txthplaceNameStatusFrm.Text;
                _objSLR.placeNamestuToPlace = txthplaceNameStatusTo.Text;
                _objSLR.studID = Get.studID;
                _objSLR.totalPassengers = "?";
                xmlUtility listings = new xmlUtility();
                XDocument element = listings.getlayout(_objSLR);

                string stringXml = element.ToString();
                var httpClient = new Windows.Web.Http.HttpClient();
                var info = AppStatic.WebServiceAuthentication;
                var token = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(info));
                httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Basic", token);
                httpClient.DefaultRequestHeaders.Add("SOAPAction", "");
                Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, _url);
                httpRequestMessage.Headers.UserAgent.TryParseAdd("Mozilla/4.0");
                IHttpContent content = new HttpStringContent(stringXml, Windows.Storage.Streams.UnicodeEncoding.Utf8);
                httpRequestMessage.Content = content;
                Windows.Web.Http.HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage);
                string strXmlReturned = await httpResponseMessage.Content.ReadAsStringAsync();
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(strXmlReturned);
                XDocument loadedData = XDocument.Parse(strXmlReturned);
                List<XElement> _listResponse = (from t1 in loadedData.Descendants("wsResponse") select t1).ToList();
                List<getSeatlayout> responsList = new List<getSeatlayout>();
                string _msg = "";
                if (_listResponse != null)
                {
                    foreach (XElement _elemet in _listResponse)
                    {
                        getSeatlayout _obj = new getSeatlayout();
                        _obj.message = _elemet.Element("message").Value.ToString();
                        responsList.Add(_obj);
                    }
                    _msg = responsList.FirstOrDefault().message.ToString();
                }
                if (_msg != "FAILURE")
                {
                    var sdata = loadedData.Descendants("Seatlayout").
                    Select(x => new getSeatlayout
                    {
                        availableSeatNos = x.Element("availableSeatNos").Value,
                        bookedSeatNos = x.Element("bookedSeatNos").Value,
                        conductorSeatNo = x.Element("conductorSeatNo").Value,
                        ladiesAvailableSeatNos = x.Element("ladiesAvailableSeatNos").Value,
                        ladiesBookedSeatNos = x.Element("ladiesBookedSeatNos").Value,
                        maxColCount = x.Element("maxColCount").Value,
                        maxRowCount = x.Element("maxRowCount").Value,
                        column = x.Element("seatDetails").Element("seats").Element("column").Value,
                        quota = x.Element("seatDetails").Element("seats").Element("quota").Value,
                        row = x.Element("seatDetails").Element("seats").Element("row").Value,
                        seatNo = x.Element("seatDetails").Element("seats").Element("seatNo").Value,
                        seatStatus = x.Element("seatDetails").Element("seats").Element("seatStatus").Value,
                        type = x.Element("seatDetails").Element("seats").Element("type").Value,
                        busID = x.Element("service").Element("busID").Value,
                        distance = x.Element("service").Element("distance").Value,
                        endPoint = x.Element("service").Element("endPoint").Value,
                        startPoint = x.Element("service").Element("startPoint").Value,
                        placeCodestuFromPlace = x.Element("stuFromPlace").Element("placeCode").Value,
                        placeIDstuFromPlace = x.Element("stuFromPlace").Element("placeID").Value,
                        placeNamestuFromPlace = x.Element("stuFromPlace").Element("placeName").Value,
                        placeCodestuToPlace = x.Element("stuToPlace").Element("placeCode").Value,
                        placeIDstuToPlace = x.Element("stuToPlace").Element("placeID").Value,
                        placeNamestuToPlace = x.Element("stuToPlace").Element("placeName").Value,
                        totalSeats = x.Element("totalSeats").Value,
                        message = x.Element("wsResponse").Element("message").Value,
                        statusCode = x.Element("wsResponse").Element("statusCode").Value
                    });
                    
                    foreach (var item in sdata)
                    {                       
                        _objS.placeCodestuFromPlace = item.placeCodestuFromPlace;
                        _objS.placeIDstuFromPlace = item.placeIDstuFromPlace;
                        _objS.placeNamestuFromPlace = item.placeNamestuFromPlace;
                        _objS.placeCodestuToPlace = item.placeCodestuToPlace;
                        _objS.placeIDstuToPlace = item.placeIDstuToPlace;
                        _objS.placeNamestuToPlace = item.placeNamestuToPlace;
                        _getStudDetails.Add(_objS);                 
                        break;
                    }
                                                         

                    int maxrowCount;
                    int maxcolcount;
                    var _listCol = (from t1 in loadedData.Descendants("maxColCount") select t1).FirstOrDefault();
                    var _listRow = (from t1 in loadedData.Descendants("maxRowCount") select t1).FirstOrDefault();

                    maxcolcount = Convert.ToInt32(_listCol.Value.ToString());
                    maxrowCount = Convert.ToInt32(_listRow.Value.ToString());
                    int b = maxrowCount;
                    int a = maxcolcount;

                    for (int r = 0; r <= a; r++)
                    {
                        Mygrid.RowDefinitions.Add(new RowDefinition());
                    }
                    for (int c = 0; c < b; c++)
                    {
                        Mygrid.ColumnDefinitions.Add(new ColumnDefinition());
                    }                  

                    List<XElement> _srow = (from t1 in loadedData.Descendants("seats") select t1).ToList();
                    List<getSeatlayout> srow = new List<getSeatlayout>();
                    foreach (XElement _elemetsr in _srow)
                    {
                        Image img = new Image();
                        TextBlock txtSeatnumber = new TextBlock();
                        TextBlock txtType = new TextBlock();

                        txtSeatnumber.Visibility = Visibility.Visible;
                        getSeatlayout _objsr = new getSeatlayout();
                        _objsr.row = _elemetsr.Element("row").Value.ToString();
                        _objsr.column = _elemetsr.Element("column").Value.ToString();
                        _objsr.seatNo = _elemetsr.Element("seatNo").Value.ToString();
                        _objsr.type = _elemetsr.Element("type").Value.ToString();
                        _objsr.quota = _elemetsr.Element("quota").Value.ToString();
                        _objsr.seatStatus = _elemetsr.Element("seatStatus").Value.ToString();
                        srow.Add(_objsr);


                        c = Convert.ToInt32(srow.LastOrDefault().row.ToString());
                        r = Convert.ToInt32(srow.LastOrDefault().column.ToString());
                        s = Convert.ToInt32(srow.LastOrDefault().seatNo.ToString());
                        t = srow.LastOrDefault().type.ToString();
                        q = srow.LastOrDefault().quota.ToString();
                        SeatS = srow.LastOrDefault().seatStatus.ToString();

                        int nn = -(r - (a + 1));

                        img.SetValue(Grid.ColumnProperty, c - 1);
                        img.SetValue(Grid.RowProperty, nn - 1);
                        txtSeatnumber.SetValue(Grid.ColumnProperty, c - 1);
                        txtSeatnumber.SetValue(Grid.RowProperty, nn - 1);
                        txtType.SetValue(Grid.ColumnProperty, c - 1);
                        txtType.SetValue(Grid.RowProperty, nn - 1);


                        txtType.FontSize = 12;
                        txtType.Text = t.ToString();
                        txtType.Foreground = new SolidColorBrush(Colors.Black);
                        txtType.Margin = new Thickness { Left = 20, Top = 95, Right = 0, Bottom = 0 };


                        txtSeatnumber.FontSize = 12;
                        txtSeatnumber.Text = s.ToString();
                        txtSeatnumber.Foreground = new SolidColorBrush(Colors.Black);
                        txtSeatnumber.Margin = new Thickness { Left = 5, Top = 95, Right = 0, Bottom = 0 };

                        img.Height = 40;
                        img.Width = 40;
                        img.Margin = new Thickness { Left = 0, Top = 40, Right = 0, Bottom = 0 };
                        if (SeatS == "AVAILABLE")
                        {
                            img.Name = txtSeatnumber.Text + txtType.Text;
                            img.Source = new BitmapImage(new System.Uri("ms-appx:///Assets/Seats/ss_empty_seat.png"));
                            img.Tapped += img_Tapped;

                        }
                        else
                        {
                            img.Source = new BitmapImage(new System.Uri("ms-appx:///Assets/Seats/ss_booked_seat.png"));
                        }


                        for (int row = 0; row < Mygrid.RowDefinitions.Count; row++)
                        {
                            for (int column = 0; column < Mygrid.ColumnDefinitions.Count; column++)
                            {
                                if (nn == row && c == column)
                                {
                                    txtSeatnumber.Visibility = Visibility.Visible;
                                    txtType.Visibility = Visibility.Visible;
                                    img.Visibility = Visibility.Visible;
                                    Mygrid.Children.Add(txtSeatnumber);
                                    Mygrid.Children.Add(img);
                                    Mygrid.Children.Add(txtType);
                                }
                            }
                        }
                    }
                    LoderPopup.Visibility = Visibility.Collapsed;
                }
                else
                {
                    LoderPopup.Visibility = Visibility.Collapsed;
                }
             }).AsTask();
            }

            catch (Exception e)
            {
                var messagedialog = new Windows.UI.Popups.MessageDialog("There is service not available");
            }          
          
        }