public ActionResult CreateTicket()
        {
            TicketOrder t = new TicketOrder();
            t.Date = DateTime.Now;
            t.ApplicationUserId = User.Identity.GetUserId();

            _TicketManager.CreateTicketOrder(t);
            return RedirectToAction("AddTicket", new { id = t.OrderId });
        }
        public void AdjustStock(TicketOrder t)
        {
            var type = new TicketType();
            foreach(var lines in t.TicketLines)
            {
                type = lines.TicketType;
                type.Stock -= lines.NumberOfItems;
                _ITicketMetaRepository.UpdateTicketType(type.TicketTypeId, type);
                //_ITicketMetaRepository.FindTicketType(lines.TicketType.TicketTypeId);
                // lines.NumberOfItems;

            }
            // _ITicketMetaRepository.UpdateTicketType()
        }
        public void CreateTickeLine(int id, TicketLine orderline, string currentUser)
        {
            TicketOrder t = new TicketOrder();
            t = FindTicket(id);
            if (currentUser == t.ApplicationUserId && !t.Paid)
            {
                TicketType tt = _ITicketMetaRepository.FindTicketType(orderline.TicketTypeId);

                if (tt.Stock >= orderline.NumberOfItems/* && k.InProces == false*/)
                {
                    TicketLine o = orderline;
                    o.OrderId = id;
                    double price = tt.Price * orderline.NumberOfItems;
                    o.PriceAmount += price;

                    _ITicketRepository.createTicketLine(orderline);
                    t.TotalAmount += price;

                    UpdateOrder(id, t);
                }
            }

        }
 public void UpdateOrder(int id, TicketOrder ticketOrder)
 {
     _ctx.Entry(_ctx.TicketOrders.Find(id)).CurrentValues.SetValues(ticketOrder);
     _ctx.SaveChanges();
 }
 //Maakt een ticketorder aan
 public void CreateTicketOrder(TicketOrder ticketOrder)
 {
     _ITicketRepository.CreateTicketOrder(ticketOrder);
 }
        //Een order op deleted zetten of undeleted
        //public void ToggleDeleted(int id, string userId)
        //{
        //    KitchenOrder k = Find(id);
        //    if (k.Deleted)
        //    {
        //        k.Deleted = false;
        //    }
        //    else
        //    {
        //        k.Deleted = true;

        //        // only make a creditorder when there doesn't excists one
        //        if (k.Paid == true && _OrderRepository.FindCreditForOrder(id) == null)
        //        {
        //            CreditOrder c = new CreditOrder();
        //            c.Date = DateTime.Now;
        //            c.CreditForOrderId = id;
        //            c.AdminId = userId;
        //            c.TotalAmount -= k.TotalAmount;
        //            c.ApplicationUserId = k.ApplicationUserId;
        //            _OrderRepository.CreateCreditOrder(c);
        //        }
        //    }
        //    UpdateOrder(id, k);
        //}

        //een ticketorder updaten
        public void UpdateOrder(int id, TicketOrder order)
        {
            order.DateEdited = DateTime.Now;
            _ITicketRepository.UpdateTicketOrder(id, order);
        }
 public void CreateTicketOrder(TicketOrder ticketOrder)
 {
     _ctx.TicketOrders.Add(ticketOrder);
     _ctx.SaveChanges();
 }