Пример #1
0
        public ActionResult Index(Consulta model)
        {
            List<Ingrediente> list = SearchIngredientes(model);
            ViewBag.table = ConvertToTable(list);
            // Opciones para hacer busquedas por Tipo de Ingrediente.
            List<SelectListItem> tipos_ingrediente = new List<SelectListItem>();
            SetTiposIngrediente(tipos_ingrediente);
            ViewBag.Tipos = tipos_ingrediente;

            return View();
        }
Пример #2
0
        private List<Ingrediente> SearchIngredientes(Consulta model)
        {
            List<Ingrediente> list = new List<Ingrediente>();

            object value;
            int x;
            if (model.by == 0 && int.TryParse(model.keyword, out x))
                value = x;
            else if (model.by == 2)
                value = model.type;
            else
                value = model.keyword as string;

            var ingredientes = new Read().ReadIngredientes((short)model.by, value);
            foreach (var i in ingredientes)
                list.Add(new Ingrediente
                {
                    Id = i.Id,
                    Nombre = i.Nombre,
                    Tipo = i.Tipo,
                    StringTipoIngrediente = i.StringTipoIngrediente,
                    Cantidad = i.Cantidad
                });

            return list;
        }