internal List <ProductSearchTotalResultVM> GetSearchTotalResult(GetSearchResult data) { try { List <ProductSearchTotalResultVM> searchResult = context.Products .Where(p => p.Name.Contains(data.searchText) && (data.storeIds.Length == 0 || p.Products2Stores.Any(o => data.storeIds.Contains(o.StoreId)))) .Select(p => new ProductSearchTotalResultVM { Name = p.Name, Id = p.Id, Brand = p.Brand, ImgUrl = p.ImgUrl, Price = p.Price, Rating = GetAVGRating(p.Rating), TotalComments = p.Rating.Count() }) .OrderByDescending(o => o.Rating) .ToList(); return(searchResult); } catch { return(null); } }
private async void SearchButton_Clicked(object sender, EventArgs e) { GetSearchResult getSearchResult = new GetSearchResult(SearchEntry.Text); var searchResult = getSearchResult.getAllContent(); await DisplayAlert(searchResult.Result.id, searchResult.Result.total.ToString(), "ok"); await DisplayAlert("Title", searchResult.Result.data[0].ToString(), "ok"); }
public IActionResult GetSearchTotalValue([FromBody] GetSearchResult data) { return(Json(service.GetSearchTotalResult(data))); }