public List <RestauranteViewModel> FiltroRestaurante(string nome = null) { List <Restaurante> restaurantes = repRestaurante.RetornaTodos().ToList(); if (nome != null) { restaurantes = restaurantes.Where(r => r.Nome.ToUpper().Contains((nome.ToUpper()))).ToList(); } var rest = new List <RestauranteViewModel>(); foreach (var item in restaurantes) { RestauranteViewModel r = new RestauranteViewModel() { RestauranteId = item.RestauranteId, Nome = item.Nome }; rest.Add(r); } return(rest); }
// GET: Prato/Create public ActionResult Create() { ViewBag.Restaurante = new SelectList(restrep.RetornaTodos(), "RestauranteId", "Nome"); return(View()); }