예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            VendaIngresso vendaIngresso = db.VendaIngressoes.Find(id);

            db.VendaIngressoes.Remove(vendaIngresso);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
 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));
 }
예제 #3
0
        // 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));
        }
예제 #4
0
        // 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));
        }
예제 #5
0
        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));
        }