public void SetDictionary(DictionaryLimits dictionaryLimits, List <Limits> limitsList) { DataSource = new List <LimitsItem>(); foreach (var item in dictionaryLimits.ProvidersList) { foreach (var pr in item.ListProviders) { LimitsItem lI = new LimitsItem(); var tmplist = dictionaryLimits.FuelTypesList.Where(ft => ft.Title == pr); var currentLimit = limitsList.Find(l => l.FuelType == pr); List <string> _tmplist = new List <string>(); foreach (var t in tmplist) { _tmplist.AddRange(t.ListFuelTypes); } lI.LimitsName = pr; lI.FuelTypesList = _tmplist; lI.LimitTypes = dictionaryLimits.LimitTypes; lI.RefuilimgStations = dictionaryLimits.RefuilimgStations; lI.Country = dictionaryLimits.Country; if (currentLimit != null) { lI.FuelAmount = currentLimit.FuelAmount; lI.CurrentFuelType = currentLimit.FuelUnits; lI.CurrentlimitType = currentLimit.LimitType; } DataSource.Add(lI); } } }
public async Task <DictionaryLimits> GetLimitsFromProvider(string provider) { DictionaryLimits dictionaryLimits = await GetDictionaryLimits(); var providerslimits = dictionaryLimits.ProvidersList.Where(pr => pr.Title == provider); dictionaryLimits.ProvidersList = (List <Provider>)providerslimits; return(dictionaryLimits); }
public async Task <DictionaryLimits> GetDictionaryLimits() { Answer answer = new Answer(); List <Provider> ProvidersList = new List <Provider>(); List <FuelTypes> FuelTypesList = new List <FuelTypes>(); DictionaryLimits dictionaryLimits = new DictionaryLimits(); Dictionary <string, List <string> > ProvidersDictionary; Dictionary <string, List <string> > FuelTypesDictionary; try { answer = await networkservice.NetworkRequest(NetworkService.TaskType.DictionaryLimits, authmanager.GetAuthData(), null); if (answer != null && answer.ResData is JObject jData) { dictionaryLimits = JsonConvert.DeserializeObject <DictionaryLimits>(jData.ToString()); if (jData.TryGetValue("providers", out JToken jToken)) { ProvidersDictionary = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(jToken.ToString()); if (ProvidersDictionary != null && ProvidersDictionary.Count > 0) { foreach (KeyValuePair <string, List <string> > entry in ProvidersDictionary) { Provider provider = new Provider(); provider.Title = entry.Key; provider.ListProviders = entry.Value; ProvidersList.Add(provider); } } } if (jData.TryGetValue("fuel_type", out JToken jTokenFuel)) { FuelTypesDictionary = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(jTokenFuel.ToString()); if (FuelTypesDictionary != null && FuelTypesDictionary.Count > 0) { foreach (KeyValuePair <string, List <string> > entry in FuelTypesDictionary) { FuelTypes fuelType = new FuelTypes(); fuelType.Title = entry.Key; fuelType.ListFuelTypes = entry.Value; FuelTypesList.Add(fuelType); } } } dictionaryLimits.ProvidersList = ProvidersList; dictionaryLimits.FuelTypesList = FuelTypesList; } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } return(dictionaryLimits); }
public async Task LoadCards(Dictionary <string, object> _filterParams) { if (ItemSource == null || UserIdforCurrentSource != authSettings.Active) { ItemSource = await cardManager.GetCrds(null); UserIdforCurrentSource = authSettings.Active; } if (_filterParams != null) { ItemSource = await cardManager.GetCrds(_filterParams); } if (dictionaryLimits == null) { dictionaryLimits = await cardManager.GetDictionaryLimits(); } }
public ChangeLimitsPage(DictionaryLimits dictionaryLimits, List <Limits> li, string Country, string RefuelStations, string cardNumber) { InitializeComponent(); viewModel.SetDictionary(dictionaryLimits, li); Number = cardNumber; Stations = RefuelStations; _Country = Country; BindingContext = viewModel; var _saveLimitsButton = new ToolbarItem() { IconImageSource = "ic_ok" }; ToolbarItems.Add(_saveLimitsButton); _saveLimitsButton.Clicked += SaveButtonClicked; }
public async Task <DictionaryLimits> GetLimitsFromProvider(string provider) { DictionaryLimits tmpLimits = new DictionaryLimits(); if (dictionaryLimits != null || dictionaryLimits.ProvidersList.Count > 0) { tmpLimits = (DictionaryLimits)dictionaryLimits.Clone(); var providerslimits = tmpLimits.ProvidersList.FindAll(pr => pr.Title == provider); tmpLimits.ProvidersList = (List <Provider>)providerslimits; return(tmpLimits); } else { await LoadCards(null); var providerslimits = dictionaryLimits.ProvidersList.FindAll(pr => pr.Title == provider); tmpLimits.ProvidersList = (List <Provider>)providerslimits; return(tmpLimits); } }
public async void OnMore(object sender, EventArgs e) { var mi = (MenuItem)sender; var sc = (Card)mi.CommandParameter; if (sc.IsBlock) { var config = new AlertConfig(); config.Message = "Карта заблокирована, изменение лимитов невозможно"; config.OkText = "OK"; UserDialogs.Instance.Alert(config); } else { DictionaryLimits dic = await _viewModel.GetLimitsFromProvider(sc.Supplier); List <Limits> li = sc.CardLimits; _ = Navigation.PushAsync(new ChangeLimitsPage(dic, li, sc.Country, sc.Stations, sc.Number)); } }
public async void LimitsPopupShow(Card card) { { var cardLimitsPopup = new CardLimitsPopup(card.CardLimits, !card.IsBlock, false) { ChangeLimitsClicked = async() => { DictionaryLimits dic = await _viewModel.GetLimitsFromProvider(card.Supplier); List <Limits> li = card.CardLimits; _ = Navigation.PushAsync(new ChangeLimitsPage(dic, li, card.Country, card.Stations, card.Number)); }, BlockCard = () => { OnDelete(card); } }; CardsListView.SelectedItem = null; await PopupNavigation.Instance.PushAsync(cardLimitsPopup); } }