public List <Request> GetApprovedRequests(string Email)
        {
            PickrWebService api      = new PickrWebService();
            JSONParser      parser   = new JSONParser();
            List <Request>  requests = new List <Request>();
            JObject         json     = api.GetDriverReceivedRequests(Email, true, false);

            requests = parser.ParseRequestsList(json);

            return(requests);
        }
Beispiel #2
0
        //protected void UpdatePanel1_Load(object sender, EventArgs e)
        //{
        //    Panel1.CssClass = "hiddenPanel";

        //    if (HttpContext.Current.Session["User"] != null)
        //    {
        //        UserDetails user = (UserDetails)HttpContext.Current.Session["User"];


        //        if (user.Mode.Equals("passenger"))
        //        {
        //            List<Request> sentRequests = (List<Request>)HttpContext.Current.Session["SentRequests"];
        //            List<List<object>> requests = new List<List<object>>();
        //            List<Tuple<int, string>> requestsStatusChange;

        //            foreach (var r in sentRequests)
        //            {
        //                requests.Add(new List<object>() { r.RequestId, r.Approved, r.Rejected });
        //            }

        //            json = api.GetPassengerNotifications(requests);
        //            requestsStatusChange = parser.ParsePassengerNotifications(json);

        //            if (requestsStatusChange.Count > 0)
        //            {
        //                Panel1.CssClass = "alert alert-dismissible alert-warning notificationPanel";

        //                foreach(var r in sentRequests)
        //                {
        //                    if(r.RequestId == requestsStatusChange[0].Item1)
        //                    {
        //                        UserDetails driver = GetUserDetails(r.Offer.UserId);
        //                        Label1.Text = "Request sent to" + driver.FirstName + " was " + requestsStatusChange[0].Item2;
        //                        Image1.ImageUrl = driver.Picture;
        //                        break;
        //                    }
        //                }
        //            }
        //        }
        //    }

        //}


        public List <Request> GetNewReceivedRequests(string Email)
        {
            PickrWebService api      = new PickrWebService();
            JSONParser      parser   = new JSONParser();
            List <Request>  requests = new List <Request>();
            List <Offer>    offers   = new List <Offer>();

            JObject json = api.GetDriverReceivedRequests(Email, false, false);

            try
            {
                requests = parser.ParseRequestsList(json);
                List <int> offerIds = new List <int>();

                foreach (Request r in requests)
                {
                    offerIds.Add(r.OfferId);
                }

                if (requests.Count > 0)
                {
                    json   = api.GetRequestedOffersList(offerIds);
                    offers = parser.ParseOffersList(json);

                    foreach (var r in requests)
                    {
                        foreach (var o in offers)
                        {
                            if (r.OfferId == o.OfferId)
                            {
                                r.Offer = o;
                            }
                        }
                    }
                }

                if (requests.Count > 0)
                {
                    newRequests.Visible   = true;
                    newRequests.InnerText = requests.Count.ToString();
                }

                HttpContext.Current.Session["Requests"]        = requests;
                HttpContext.Current.Session["RequestedOffers"] = offers;
            }
            catch (Exception e)
            {
                //ErrorMessage.Text = "Error retrieving your list of sent requests.";
            }

            return(requests);
        }