public void Insert(Bebida bebida) { using(Context db = new Context()) { db.Bebida.Add(bebida); db.SaveChanges(); } }
public void Update(Bebida bebida) { using(Context db = new Context()) { db.Entry(bebida).State = EntityState.Modified; db.SaveChanges(); } }
public ActionResult Create(Bebida bebida) { try { if (ModelState.IsValid) { BebidaService bebidaService = new BebidaService(); bebidaService.Insert(bebida); TempData["message"] = "Bebida cadastrada com sucesso"; return RedirectToAction("Index"); } } catch (Exception ex) { ViewBag.Error = ex.Message; } return View(bebida); }