/// <inheritdoc /> public async Task <PlaidResult <ListOfInstitutionsResponse> > SearchInstitutions(string query, IList <string> products = null) { //conditions Condition.Requires(query).IsNotNullOrWhiteSpace(); //create the payload to pass var payload = new InstitutionSearchRequest(clientPublicKey, query, products); //serialize object HttpContent content = ContentExtensions.ToJsonContent(payload); //post it and get the response HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.Institutions_SearchInstitutions, content); //read the string string responseJson = await response.Content.ReadAsStringAsync(); //create the result PlaidResult <ListOfInstitutionsResponse> result = new PlaidResult <ListOfInstitutionsResponse>(responseJson); //is it ok if (response.StatusCode == HttpStatusCode.OK) { ListOfInstitutionsResponse listOfInstitutionsResponse = JsonConvert.DeserializeObject <ListOfInstitutionsResponse>(responseJson); result.Value = listOfInstitutionsResponse; } //parse the exception result.Exception = await this.ParseException(response, responseJson); //return return(result); }
public async Task<InstitutionListViewModel> GetPagedListAsync(InstitutionSearchRequest request) { var institutions = _institutions.AsNoTracking() .Include(a => a.Creator) .Include(a => a.LasModifier) .OrderByDescending(a => a.Name) .AsQueryable(); if (request.Term.HasValue()) institutions = institutions.Where(a => a.Name.Contains(request.Term)); var selectedInstitutions = institutions.ProjectTo<InstitutionViewModel>(_mappingEngine); var query =await selectedInstitutions .Skip((request.PageIndex - 1)*10) .Take(10).ToListAsync(); return new InstitutionListViewModel {Request = request, Institutions = query}; }
public virtual async Task<ActionResult> ListAjax(InstitutionSearchRequest request) { var viewModel = await _institutionService.GetPagedListAsync(request); if (viewModel.Institutions == null || !viewModel.Institutions.Any()) return Content("no-more-info"); return PartialView(MVC.Institution.Views._ListAjax, viewModel); }