Exemplo n.º 1
0
 public ActionResult Edit(Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.UserId = new SelectList(db.Users, "Id", "Name", order.UserId);
     return View(order);
 }
Exemplo n.º 2
0
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.UserId = new SelectList(db.Users, "Id", "Name", order.UserId);
            return View(order);
        }
Exemplo 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");
        }