Beispiel #1
0
 private static Expression <Func <AnuncioWebmotors, bool> > SetupWhere(AnuncioFilter filter)
 {
     return(s =>
            (string.IsNullOrEmpty(filter.Marca) || s.Marca.Contains(filter.Marca)) &&
            (string.IsNullOrEmpty(filter.Modelo) || s.Modelo.Contains(filter.Modelo)) &&
            (string.IsNullOrEmpty(filter.Versao) || s.Versao.Contains(filter.Versao)));
 }
        public async Task <IActionResult> Index(AnuncioFilter filter)
        {
            var anuncios = await _anuncioWebmotorsService.GetAsync(filter);

            var makes = await _anuncioWebmotorsService.GetMakes();

            var model = new AnuncioIndexViewModel
            {
                AnuncioWebmotors = anuncios,
                Marcas           = makes.Select(x => x.Name),
                Modelos          = new List <string>(),
                Versoes          = new List <string>()
            };

            return(View(model));
        }
Beispiel #3
0
 public Task <IEnumerable <AnuncioWebmotors> > GetAsync(AnuncioFilter filter)
 {
     var where = SetupWhere(filter);
     return(_repository.GetAsync(where));
 }