Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "TicketID,EventTitle,TicketRow,TicketColumn")] TicketModel ticketmodel)
        {
            if (ModelState.IsValid &&
                !(
                    db.Tickets.Any(
                        t => t.EventTitle.Equals(ticketmodel.EventTitle) &&
                        t.TicketRow.Equals(ticketmodel.TicketRow) &&
                        t.TicketColumn.Equals(ticketmodel.TicketColumn))
                    )
                &&
                dbEv.Events.Any(e => e.EventTitle.Equals(ticketmodel.EventTitle))
                )

            {
                var q = from x in dbEv.Events
                        where x.EventTitle.Equals(ticketmodel.EventTitle)
                        select x.EventTickets;

                int ticketsNr = q.FirstOrDefault();

                if (db.Tickets.Count(t => t.EventTitle.Equals(ticketmodel.EventTitle)) < ticketsNr)
                {
                    db.Tickets.Add(ticketmodel);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                //db.Tickets.Add(ticketmodel);
                //db.SaveChanges();
                //return RedirectToAction("Index");
            }

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

            return(View(ticket));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "cod_ticket,cod_reserva,estado")] Ticket ticket)
        {
            if (ModelState.IsValid)
            {
                db.Tickets.Add(ticket);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ticket));
        }
        // Being named id is important because of my routing settings. It expects a paramter named ID, not some custom more fitting name
        public ActionResult Confirmation(int?id)
        {
            if (OrderNumber.paid == false)
            {
                return(HttpNotFound());
            }
            OrderNumber.tNum = (int)id;
            var a = db.Menus.ToList();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            foreach (Ticket b in a)
            {
                b.TableNumber = (int)id;
                if (b.Status == "ordering")
                {
                    b.Status = "Preparing";
                }

                db.SaveChanges();
            }

            return(View(db.Menus.ToList()));
        }
Ejemplo n.º 5
0
        public int Save()
        {
            int ess;

            try
            {
                ess = _dbContext.SaveChanges();
                if (ess > 0)
                {
                    return(ess);
                }
                else
                {
                    throw new AppException("Hiçbir değişiklik yapılmadı.");
                }
            }
            catch (Exception ex)
            {
                throw new AppException(ex.Message);
            }
        }
 public TicketDetails BookTicket(TicketDetails ticketDetails)
 {
     ticketDB.TicketDetail.Add(ticketDetails);
     ticketDB.SaveChanges();
     return(ticketDetails);
 }