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