Esempio n. 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);
        }
Esempio n. 2
0
        //
        // GET: /Lanche/Delete/5
        public ActionResult Delete(int id)
        {
            Lanche lanche = null;

            try
            {
                LancheService lancheService = new LancheService();
                lanche = lancheService.Find(id);
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }

            return View(lanche);
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                LancheService lancheService = new LancheService();
                lancheService.Delete(id);
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }

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

            return RedirectToAction("Index");
        }
Esempio n. 4
0
        public ActionResult Create(Lanche lanche)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    LancheService lancheService = new LancheService();
                    lancheService.Insert(lanche);

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

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

            return View(lanche);
        }
Esempio n. 5
0
        //
        // GET: /Lanche/
        public ViewResult Index()
        {
            IList<Lanche> lanches = null;

            try
            {
                LancheService lancheService = new LancheService();
                lanches = lancheService.List();
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }

            return View(lanches);
        }
 public IList<Lanche> Get()
 {
     LancheService lancheService = new LancheService();
     return lancheService.List();
 }
Esempio n. 7
0
        public JsonResult GetValorLanche(int id)
        {
            LancheService lancheService = new LancheService();

            return Json(new { Result = lancheService.GetValor(id) }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 8
0
        public JsonResult GetDescricaoLanche(int id)
        {
            LancheService lancheService = new LancheService();

            return Json(new { Result = lancheService.FindDescricao(id) }, JsonRequestBehavior.AllowGet);
        }