public ActionResult DeleteConfirmed(int id) { VendaIngresso vendaIngresso = db.VendaIngressoes.Find(id); db.VendaIngressoes.Remove(vendaIngresso); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "VendaIngressoId,IngressoId,PessoaId,BilheteriaId")] VendaIngresso vendaIngresso) { if (ModelState.IsValid) { db.Entry(vendaIngresso).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BilheteriaId = new SelectList(db.Bilheterias, "BilheteriaId", "Nome", vendaIngresso.BilheteriaId); ViewBag.IngressoId = new SelectList(db.Ingressoes, "IngressoId", "IngressoId", vendaIngresso.IngressoId); ViewBag.PessoaId = new SelectList(db.Pessoas, "PessoaId", "Nome", vendaIngresso.PessoaId); return(View(vendaIngresso)); }
// GET: VendaIngressos/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VendaIngresso vendaIngresso = db.VendaIngressoes.Find(id); if (vendaIngresso == null) { return(HttpNotFound()); } return(View(vendaIngresso)); }
// GET: VendaIngressos/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VendaIngresso vendaIngresso = db.VendaIngressoes.Find(id); if (vendaIngresso == null) { return(HttpNotFound()); } ViewBag.BilheteriaId = new SelectList(db.Bilheterias, "BilheteriaId", "Nome", vendaIngresso.BilheteriaId); ViewBag.IngressoId = new SelectList(db.Ingressoes, "IngressoId", "IngressoId", vendaIngresso.IngressoId); ViewBag.PessoaId = new SelectList(db.Pessoas, "PessoaId", "Nome", vendaIngresso.PessoaId); return(View(vendaIngresso)); }
public ActionResult Create([Bind(Include = "VendaIngressoId,IngressoId,PessoaId,BilheteriaId")] VendaIngresso vendaIngresso) { if (ModelState.IsValid) { Ingresso ingresso = db.Ingressoes.Find(vendaIngresso.IngressoId); vendaIngresso.Ingresso = ingresso; if (vendaIngresso.decrementaIngresso()) { db.VendaIngressoes.Add(vendaIngresso); db.SaveChanges(); ingresso.QuantidadeIngressos -= 1; db.Entry(ingresso).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.BilheteriaId = new SelectList(db.Bilheterias, "BilheteriaId", "Nome", vendaIngresso.BilheteriaId); ViewBag.IngressoId = new SelectList(db.Ingressoes, "IngressoId", "IngressoId", vendaIngresso.IngressoId); ViewBag.PessoaId = new SelectList(db.Pessoas, "PessoaId", "Nome", vendaIngresso.PessoaId); return(View(vendaIngresso)); }