示例#1
0
 public void Update(Lanche lanche)
 {
     using(Context db = new Context())
     {
         db.Entry(lanche).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
示例#2
0
 public void Insert(Lanche lanche)
 {
     using(Context db = new Context())
     {
         db.Lanche.Add(lanche);
         db.SaveChanges();
     }
 }
示例#3
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);
        }