示例#1
0
        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);
        }
        //
        // GET: /Opcional/Delete/5
        public ActionResult Delete(int id)
        {
            Opcional opcional = null;

            try
            {
                OpcionalService opcionalService = new OpcionalService();
                opcional = opcionalService.Find(id);
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }

            return View(opcional);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                OpcionalService opcionalService = new OpcionalService();
                opcionalService.Delete(id);
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }

            if(ModelState.IsValid)
                TempData["message"] = "Opcional excluído com sucesso";

            return RedirectToAction("Index");
        }
        public ActionResult Create(Opcional opcional)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    OpcionalService opcionalService = new OpcionalService();
                    opcionalService.Insert(opcional);

                    TempData["message"] = "Opcional cadastrado com sucesso";

                    return RedirectToAction("Index");
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }

            return View(opcional);
        }
示例#5
0
        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;
        }
示例#6
0
        public JsonResult GetValorOpcional(int id)
        {
            OpcionalService opcionalService = new OpcionalService();

            return Json(new { Result = opcionalService.GetValor(id) }, JsonRequestBehavior.AllowGet);
        }
        //
        // 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);
        }