public override async Task GetItems(CancellationToken token) { var result = await CounterpartyService.GetCounterparties(Criteria, token); if (!CheckForAuthorizationErrors(result.Error)) { return; } RunOnUiThread(() => { if (result.Error.Any()) { ShowToastMessage(Resource.String.ErrorOccurred); return; } _adapter.UpdateList(result.Data); if (result.Data.Any()) { SetContent(); return; } SetEmptyContent(); }); }
private void AfterTextChanged(object sender, AfterTextChangedEventArgs eventArgs) { var editText = (EditText)sender; var text = eventArgs.Editable.ToString(); if (editText.Id == AddInvoiceCity.Id) { var token = CancelAndSetTokenForView(AddInvoiceCity); Criteria.Name = text; var task = Task.Run(async() => { var cityResult = await CityService.GetCities(Criteria, token); RunOnUiThread(() => { _cityAdapter.UpdateList(cityResult.Data); }); }, token); } if (editText.Id == AddInvoiceCounterparty.Id) { var token = CancelAndSetTokenForView(AddInvoiceCounterparty); Criteria.Name = text; var task = Task.Run(async() => { var counterpartyResult = await CounterpartyService.GetCounterparties(Criteria, token); RunOnUiThread(() => { _counterPartyAdapter.UpdateList(counterpartyResult.Data); }); }, token); } }
public async Task Load(CancellationToken token) { var counterpartyResult = await CounterpartyService.GetCounterparties(Criteria, token); var paymentMethodsResult = await InvoiceService.GetPaymentMethods(token); var invoiceTypesResult = await InvoiceService.GetInvoiceTypes(token); if (counterpartyResult.Error.Any()) { ShowToastMessage(Resource.String.ErrorOccurred); return; } var paymentMethodPrompt = Resources.GetString(Resource.String.PaymentMethodPrompt); var invoiceTypePrompt = Resources.GetString(Resource.String.InvoiceTypePrompt); paymentMethodsResult.Data[0].Name = GetString("PaymentMethod.Cash"); paymentMethodsResult.Data[1].Name = GetString("PaymentMethod.Card"); invoiceTypesResult.Data[0].Name = GetString("InvoiceType.Sales"); invoiceTypesResult.Data[1].Name = GetString("InvoiceType.Purchase"); paymentMethodsResult.Data.Insert(0, new Models.KeyValue { Id = -1, Name = paymentMethodPrompt }); invoiceTypesResult.Data.Insert(0, new Models.KeyValue { Id = -1, Name = invoiceTypePrompt }); RunOnUiThread(() => { _invoiceTypeAdapter.UpdateList(paymentMethodsResult.Data); _paymentMethodAdapter.UpdateList(invoiceTypesResult.Data); _counterPartyAdapter.UpdateList(counterpartyResult.Data); }); }