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: /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); }
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"); }
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); }
// // 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(); }
public JsonResult GetValorLanche(int id) { LancheService lancheService = new LancheService(); return Json(new { Result = lancheService.GetValor(id) }, JsonRequestBehavior.AllowGet); }
public JsonResult GetDescricaoLanche(int id) { LancheService lancheService = new LancheService(); return Json(new { Result = lancheService.FindDescricao(id) }, JsonRequestBehavior.AllowGet); }