async Task LoadOrders(string value)
        {
            LoadingManager.OnLoading();
            Status _statusvalue = (Status)Enum.Parse(typeof(Status), value);

            var orderData = await orderDataStore.GetOrdersOfUserWithSpecificStatus(App.LogUser.UserId, _statusvalue, App.TokenDto.Token);


            KeyValues.Clear();

            KeyValues.Add("orderAdded", orderData);

            UserOrders.Clear();

            foreach (var item in orderData)
            {
                item.StoreOrder = await StoreDataStore.GetItemAsync(item.StoreId.ToString());

                var presenter = new OrderPresenter(item);

                UserOrders.Add(presenter);
            }

            LoadingManager.OffLoading();
        }
示例#2
0
 public void FromJson(JsonNode jn)
 {
     KeyValues.Clear();
     Accounts.Clear();
     KeyValues.LookupFromJsonValues((JsonPairs)jn, (t) => t.Item1 != "accounts");
     if (((JsonPairs)jn).KeyValues.TryGetValue("accounts", out var js))
     {
         Accounts.LookupFromJson((JsonPairs)js, CreateAccountFromJson);
     }
 }
示例#3
0
 public void getMedicineStatisticByDrug()
 {
     try
     {
         KeyValues.Clear();
         string medicineId = null;
         if (MedicineSelected != null)
         {
             medicineId = ChartM.GetMedicineId(MedicineSelected);
         }
         foreach (var item in ChartM.GetStatistic(DateStart, DateFinish, medicineId))
         {
             KeyValues.Add(new KeyValuePair <string, int>(item.Key, item.Value));
         }
     }
     catch (Exception e)
     {
         (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString();
     }
 }
示例#4
0
 /// <summary>
 /// 清空集合
 /// </summary>
 public void Clear()
 {
     KeyValues.Clear();
 }
        async Task LoadUserOrderWithStatus(string value)
        {
            LoadingManager.OnLoading();
            Status _statusvalue = (Status)Enum.Parse(typeof(Status), value);

            var orderData = await orderDataStore.GetOrdersOfUserWithSpecificStatus(App.LogUser.UserId, _statusvalue, App.TokenDto.Token);

            if (!KeyValues.ContainsKey("orderAdded"))
            {
                KeyValues.Add("orderAdded", orderData);
            }


            switch (_statusvalue)
            {
            case Status.Completed:
            {
                List <Order> tempData = new List <Order>();

                var data = await orderDataStore.GetOrdersOfUserWithSpecificStatusDifferent(KeyValues["orderAdded"], _statusvalue, App.LogUser.UserId);

                if (data != null)
                {
                    foreach (var item in KeyValues["orderAdded"])
                    {
                        if (!tempData.Any(o => o.OrderId == item.OrderId))
                        {
                            tempData.Add(item);
                        }
                    }

                    foreach (var item in data)
                    {
                        if (!tempData.Any(s => s.StoreId == item.StoreId))
                        {
                            tempData.Add(item);
                        }
                    }

                    KeyValues.Clear();
                    KeyValues.Add("orderAdded", tempData);


                    foreach (var item in KeyValues["orderAdded"])
                    {
                        if (!UserOrders.Any(s => s.OrderId == item.OrderId))
                        {
                            //Task.Run(async() =>
                            //{
                            //    item.StoreOrder = await StoreDataStore.GetItemAsync(item.StoreId.ToString());

                            //}).Wait();

                            item.StoreOrder = await StoreDataStore.GetItemAsync(item.StoreId.ToString());

                            var presenter = new OrderPresenter(item);

                            UserOrders.Add(presenter);
                        }
                    }
                }



                break;
            }

            case Status.NotSubmited:
            {
                List <Order> tempData = new List <Order>();

                var data = await orderDataStore.GetOrdersOfUserWithSpecificStatusDifferent(KeyValues["orderAdded"], _statusvalue, App.LogUser.UserId);

                if (data != null)
                {
                    foreach (var item in KeyValues["orderAdded"])
                    {
                        if (!tempData.Any(o => o.OrderId == item.OrderId))
                        {
                            tempData.Add(item);
                        }
                    }

                    foreach (var item in data)
                    {
                        if (!tempData.Any(s => s.StoreId == item.StoreId))
                        {
                            tempData.Add(item);
                        }
                    }

                    KeyValues.Clear();
                    KeyValues.Add("orderAdded", tempData);


                    foreach (var item in KeyValues["orderAdded"])
                    {
                        if (!UserOrders.Any(s => s.OrderId == item.OrderId))
                        {
                            item.StoreOrder = await StoreDataStore.GetItemAsync(item.StoreId.ToString());

                            var presenter = new OrderPresenter(item);

                            UserOrders.Add(presenter);
                        }
                    }
                }

                break;

                //UserOrders.Clear();

                //foreach (var item in orderData)
                //{

                //    item.StoreOrder = await StoreDataStore.GetItemAsync(item.StoreId.ToString());
                //    var presenter = new OrderPresenter(item);

                //    UserOrders.Add(presenter);
                //}
            }

            case Status.Submited:
            {
                List <Order> tempData = new List <Order>();

                var data = await orderDataStore.GetOrdersOfUserWithSpecificStatusDifferent(KeyValues["orderAdded"], _statusvalue, App.LogUser.UserId);

                if (data != null)
                {
                    foreach (var item in KeyValues["orderAdded"])
                    {
                        if (!tempData.Any(o => o.OrderId == item.OrderId))
                        {
                            tempData.Add(item);
                        }
                    }

                    foreach (var item in data)
                    {
                        if (!tempData.Any(s => s.StoreId == item.StoreId))
                        {
                            tempData.Add(item);
                        }
                    }

                    KeyValues.Clear();
                    KeyValues.Add("orderAdded", tempData);


                    foreach (var item in KeyValues["orderAdded"])
                    {
                        if (!UserOrders.Any(s => s.OrderId == item.OrderId))
                        {
                            item.StoreOrder = await StoreDataStore.GetItemAsync(item.StoreId.ToString());

                            var presenter = new OrderPresenter(item);

                            UserOrders.Add(presenter);
                        }
                    }
                }


                //UserOrders.Clear();

                //foreach (var item in orderData)
                //{

                //    item.StoreOrder = await StoreDataStore.GetItemAsync(item.StoreId.ToString());
                //    var presenter = new OrderPresenter(item);

                //    UserOrders.Add(presenter);
                //}

                break;
            }

            default:
                break;
            }

            LoadingManager.OffLoading();
        }