public async Task <IEnumerable <SelectOption> > GetFarmTypesAsync(BaseSelectFilterModel criterias) { if (criterias == null) { criterias = new BaseSelectFilterModel(); } var categories = await _farmTypeService.SearchAsync(new BaseFilter { Keyword = criterias.Query, PageSize = _pagerOptions.PageSize, Page = _defaultPageSelection }); if (categories == null || !categories.Any()) { return(new List <SelectOption>()); } var categorySeletions = categories .Select(x => new SelectOption { Id = x.Id.ToString(), Text = x.Name }); return(categorySeletions); }
public async Task <IActionResult> Search(string q) { var farmTypes = await _farmTypeService.SearchAsync(new BaseFilter { Keyword = q, Page = _defaultPageSelection, PageSize = _pagerOptions.PageSize }); if (farmTypes == null || !farmTypes.Any()) { return(Json(new List <Select2ItemModel>())); } var farmTypesSeletions = farmTypes .Select(x => new Select2ItemModel { Id = x.Id.ToString(), Text = x.Name }); return(Json(farmTypesSeletions)); }