Ejemplo n.º 1
0
        public ActionResult Create(Ticket ticket)
        {
            if (ModelState.IsValid)
            {
                db.Tickets.Add(ticket);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.DateId = new SelectList(db.Dates, "Id", "Id", ticket.DateId);
            ViewBag.PlaceId = new SelectList(db.Places, "Id", "Id", ticket.PlaceId);
            ViewBag.OrderId = new SelectList(db.Orders, "Id", "Id", ticket.OrderId);
            return View(ticket);
        }
Ejemplo n.º 2
0
 public ActionResult Edit(Ticket ticket)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticket).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.DateId = new SelectList(db.Dates, "Id", "Id", ticket.DateId);
     ViewBag.PlaceId = new SelectList(db.Places, "Id", "Id", ticket.PlaceId);
     ViewBag.OrderId = new SelectList(db.Orders, "Id", "Id", ticket.OrderId);
     return View(ticket);
 }
Ejemplo n.º 3
0
        public ActionResult ConfirmOrder(int? idPlay, int? idPlace)
        {
            if (AuthorizationHelper.IsAccess(AuthorizationHelper.UserRole, Session))
            {
                Play p = db.Plays.Find(idPlay);
                Place pc = db.Places.Find(idPlace);

                if (p != null && pc != null)
                {
                    Order order = new Order();
                    order.UserId = AuthorizationHelper.CurrentUser(Session).Id;
                    db.Orders.Add(order);


                    //db.SaveChanges();

                    Ticket ticket = new Ticket();
                    ticket.Serial = Guid.NewGuid().ToString();
                    //TODO
                    //ticket.Play = p;
                    ticket.Place = pc;
                    ticket.OrderId = order.Id;
                    db.Tickets.Add(ticket);

                    db.SaveChanges();
                  
    //order.Tickets.Add(ticket

                }
                else
                {
                    RedirectToAction("Index");
                }

                //return View();

                // TODO message about success confirmation
                //if (ModelState.IsValid)
            }
            return RedirectToAction("Index");
        }