public ActionResult Index() { Home home = new Home(); try { if (User.Identity.IsAuthenticated) { // Carrega o cardápio LancheService lancheService = new LancheService(); home.Lanches = lancheService.List(); OpcionalService opcionalService = new OpcionalService(); home.Opcionais = opcionalService.List(); BebidaService bebidaService = new BebidaService(); home.Bebidas = bebidaService.List(); } } catch (Exception ex) { ViewBag.Error = ex.Message; } return View(home); }
private Pedido InicializaTela(Pedido pedido) { // Opcionais OpcionalService opcionalService = new OpcionalService(); pedido.Opcionais = opcionalService.List(); using (Context db = new Context()) { // DropDownList Bebida if(pedido.BebidaId != 0) ViewBag.BebidaId = new SelectList(db.Bebida.ToList(), "Id", "Nome", pedido.BebidaId); else ViewBag.BebidaId = new SelectList(db.Bebida.ToList(), "Id", "Nome"); // DropDownList Lanche if(pedido.LancheId != 0) ViewBag.LancheId = new SelectList(db.Lanche.ToList(), "Id", "Nome", pedido.LancheId); else ViewBag.LancheId = new SelectList(db.Lanche.ToList(), "Id", "Nome"); } return pedido; }
// // GET: /Opcional/ public ViewResult Index() { IList<Opcional> opcionals = null; try { OpcionalService opcionalService = new OpcionalService(); opcionals = opcionalService.List(); } catch (Exception ex) { ViewBag.Error = ex.Message; } return View(opcionals); }