예제 #1
0
        public async override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);
            switch (parameters.GetNavigationMode())
            {
            case NavigationMode.Back:
                if (parameters.ContainsKey("History"))
                {
                    var history = parameters["History"] as ImportExportHistoryDto;
                    ListHistoryBindProp.Insert(0, history);
                }
                break;

            case NavigationMode.New:
                using (var client = new HttpClient())
                {
                    var response = await client.GetAsync(Properties.Resources.BaseUrl + "items/");

                    if (response.IsSuccessStatusCode)
                    {
                        var items = JsonConvert.DeserializeObject <IEnumerable <ItemDto> >(await response.Content.ReadAsStringAsync());
                        ListItemBindProp           = new ObservableCollection <ItemDto>(items.Where(i => i.IsManaged && i.CurrentQuantity >= i.MinQuantity));
                        ListItemOutOfStockBindProp = new ObservableCollection <ItemDto>(items.Where(i => i.IsManaged && i.CurrentQuantity < i.MinQuantity));
                    }
                    response = await client.GetAsync(Properties.Resources.BaseUrl + "histories/");

                    if (response.IsSuccessStatusCode)
                    {
                        var histories = JsonConvert.DeserializeObject <IEnumerable <ImportExportHistoryDto> >(await response.Content.ReadAsStringAsync());
                        ListHistoryBindProp = new ObservableCollection <ImportExportHistoryDto>(histories);
                    }
                }
                break;

            case NavigationMode.Forward:
                break;

            case NavigationMode.Refresh:
                break;

            default:
                break;
            }
        }
예제 #2
0
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            switch (parameters.GetNavigationMode())
            {
            case NavigationMode.Back:
                if (parameters.ContainsKey(Keys.HISTORY))
                {
                    var history = parameters[Keys.HISTORY] as VisualHistoryModel;
                    ListHistoryBindProp.Insert(0, history);
                    RaisePropertyChanged(nameof(ListHistoryBindProp));
                }
                if (_item.CurrentQuantity > _item.MinQuantity)
                {
                    if (ListRunOutItemBindProp.Any(h => h.Id == _item.Id))
                    {
                        ListRunOutItemBindProp.Remove(_item);
                        ListItemBindProp.Add(_item);
                        RaisePropertyChanged(nameof(ListItemBindProp));
                    }
                }
                else
                {
                    if (ListItemBindProp.Any(h => h.Id == _item.Id))
                    {
                        ListItemBindProp.Remove(_item);
                        ListRunOutItemBindProp.Add(_item);
                        RaisePropertyChanged(nameof(ListRunOutItemBindProp));
                    }
                }
                break;

            case NavigationMode.New:
                GetData();
                break;

            case NavigationMode.Forward:
                break;

            case NavigationMode.Refresh:
                break;
            }
        }