public async Task FetchOrders()
        {
            try
            {
                OrderDetails.Clear();
                RequestedOrders.Clear();
                CancelOrders.Clear();
                CompleteOrders.Clear();
                ProductList.Clear();
                CustomerOrders orders = await this.orderDataService.GetOrderedItemsAsync();

                if (orders != null)
                {
                    foreach (var item in orders.Data.CustomerInvoiceData)
                    {
                        OrderDetails.Add(item);
                        if (!string.IsNullOrEmpty(item.OrderStatus))
                        {
                            if (item.OrderStatus.ToLower() == "inprogress")
                            {
                                RequestedOrders.Add(item);
                            }
                            else if (item.OrderStatus.ToLower() == "rejected")
                            {
                                CancelOrders.Add(item);
                            }
                            else if (item.OrderStatus.ToLower() == "delivered")
                            {
                                CompleteOrders.Add(item);
                            }
                        }
                    }

                    foreach (var item in orders.Data.InvocieLineItems)
                    {
                        ProductList.Add(item);
                    }
                }
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert("msg", "Unable to load order list", "ok");
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #2
0
        public async Task FetchOrders()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    OrderDetails.Clear();
                    RequestedOrders.Clear();
                    CancelOrders.Clear();
                    CompleteOrders.Clear();
                    ProductList.Clear();
                    CustomerOrders orders = await this.orderDataService.GetOrderedItemsAsync();

                    if (orders != null)
                    {
                        foreach (var item in orders.Data.CustomerInvoiceData)
                        {
                            OrderDetails.Add(item);
                            if (!string.IsNullOrEmpty(item.OrderStatus))
                            {
                                if (item.OrderStatus.ToLower().Replace(" ", "") == "ontheway" || item.OrderStatus.ToLower().Replace(" ", "") == "packed" ||
                                    item.OrderStatus.ToLower().Replace(" ", "") == "inprogress" || item.OrderStatus.ToLower().Replace(" ", "") == "accepted")
                                {
                                    RequestedOrders.Add(item);
                                }
                                else if (item.OrderStatus.ToLower() == "cancelled" || item.OrderStatus.ToLower() == "rejected")
                                {
                                    CancelOrders.Add(item);
                                }
                                else if (item.OrderStatus.ToLower() == "delivered")
                                {
                                    CompleteOrders.Add(item);
                                }
                            }
                        }

                        foreach (var item in orders.Data.InvocieLineItems)
                        {
                            ProductList.Add(item);
                        }
                    }
                }
                catch (Exception e)
                {
                    try
                    {
                        DependencyService.Get <IToastMessage>().LongTime("Unable to load order list");
                    }
                    catch { }
                }
                finally
                {
                    IsBusy = false;
                }
            }
            else
            {
                try
                {
                    DependencyService.Get <IToastMessage>().LongTime("Check your Internet Connection to reload the list");
                }
                catch { }
                IsBusy = false;
            }
        }