public List <Beer> FiltringBeers(string searchBarText, object breweryListObject, object typeListObject, double value)
        {
            List <Beer> beers = new List <Beer>();

            if (breweryListObject == null && typeListObject == null)
            {
                return(beers = Beers.Where(i => ((i.BrewerName.ToLower().Contains(searchBarText.ToLower()) ||
                                                  (i.TypeName.ToLower().Contains(searchBarText.ToLower())))) && (i.Quantity > (int)value)).ToList());
            }
            else if (breweryListObject == null)
            {
                Models.Type type = (Models.Type)typeListObject;

                return(beers = Beers.Where(i => ((i.BrewerName.ToLower().Contains(searchBarText.ToLower()) ||
                                                  (i.TypeName.ToLower().Contains(searchBarText.ToLower())))) && (i.Quantity > (int)value) && (i.TypeID == type.TypeID)).ToList());
            }
            else if (typeListObject == null)
            {
                Brewery brewery = (Brewery)breweryListObject;
                return(beers = Beers.Where(i => ((i.BrewerName.ToLower().Contains(searchBarText.ToLower()) ||
                                                  (i.TypeName.ToLower().Contains(searchBarText.ToLower())))) && (i.Quantity > (int)value) && (i.BreweryID == brewery.BreweryID)).ToList());
            }
            else
            {
                Brewery     brewery = (Brewery)breweryListObject;
                Models.Type type    = (Models.Type)typeListObject;
                return(beers = Beers.Where(i => ((i.BrewerName.ToLower().Contains(searchBarText.ToLower()) ||
                                                  (i.TypeName.ToLower().Contains(searchBarText.ToLower())))) && (i.Quantity > (int)value) && (i.BreweryID == brewery.BreweryID) && (i.TypeID == type.TypeID)).ToList());
            }
        }
Пример #2
0
 private void Filter(string toSearch)
 {
     if (!string.IsNullOrEmpty(toSearch))
     {
         Beers = Beers.Where(beer => beer.Name.Contains(toSearch));
     }
     FilterModel = new FilterViewModel(toSearch);
 }
Пример #3
0
        public void OnGet()
        {
            var beer    = new RestClient("https://localhost:44371/api/Beers");
            var request = new RestRequest(Method.GET);

            request.AddHeader("content-type", "application/json");
            IRestResponse response = beer.Execute(request);

            Beers = JsonConvert.DeserializeObject <List <Beer> >(response.Content);
            Beers.Where(b => b.Marca == "Heineken").ToList();
        }