public async Task <IList <ContactDTO> > GetCandidateAsync(ContactCandidateRequest model) { IList <ContactDTO> CandidateList = new List <ContactDTO>(); using (var httpClient = GetHttpClient()) { var stringContent = new List <KeyValuePair <string, string> >(); stringContent.Add(new KeyValuePair <string, string>("TOKEN", model.TOKEN)); stringContent.Add(new KeyValuePair <string, string>("KEYWORD", model.KEYWORD)); var content = new MultipartFormDataContent(); foreach (var keyValuePair in stringContent) { content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key); } var response = await httpClient.PostAsync(ServerURL.GetContactCandidateURL, content); if (response.StatusCode == System.Net.HttpStatusCode.OK) { string retVal = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var responseItem = JsonConvert.DeserializeObject <CommonResponse>(retVal); if (responseItem.RESULT) { CandidateList = JsonConvert.DeserializeObject <List <ContactDTO> >(responseItem.MSG); } } } return(CandidateList); }
async Task <bool> ExecuteLoadCandidateList(ContactCandidateRequest model) { if (IsBusy) { return(true); } IsBusy = true; try { CandiateList.Clear(); var CandidateResultFromStore = await DataStore.GetCandidateAsync(model); if (CandidateResultFromStore == null) { CandidateResultFromStore = new List <ContactDTO>(); } foreach (var item in CandidateResultFromStore) { CandiateList.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } return(true); }
void SearchView_QueryTextSubmit(object sender, Android.Support.V7.Widget.SearchView.QueryTextSubmitEventArgs e) { if (!string.IsNullOrEmpty(e.Query) && CrossConnectivity.Current.IsConnected) { ContactCandidateRequest model = new ContactCandidateRequest() { KEYWORD = e.Query, TOKEN = MyApplication.Me.TOKEN }; EngineService.EngineInstance.ContactListViewModel.LoadAllCandiateListItemCommand.Execute(model); } else { DialogUtils.ShowOKDialog(this, @"warning", "Network is disconnected"); } }