// GET: Bestellinghistoriek
        public ActionResult Index()
        {
            tblBestellingService         bestellingservice = new tblBestellingService();
            BestellinghistoriekViewModel vm = new BestellinghistoriekViewModel();
            tblBestellijnService         bestellijnservice = new tblBestellijnService();
            tblProductService            productservice    = new tblProductService();

            var claimsIdentity = User.Identity as ClaimsIdentity;

            if (claimsIdentity != null)
            {
                var userIdClaim = claimsIdentity.Claims
                                  .FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier);

                if (userIdClaim != null)
                {
                    string id = userIdClaim.Value;

                    IEnumerable <tblBestelling> bestellijst = bestellingservice.getBestellingenBytblGebruiker(id);
                    vm.bestellingID = bestellijst.Select(a => a.BestellingID).ToArray();
                    vm.besteldatum  = bestellijst.Select(a => a.Besteldatum).ToArray();
                    vm.vertekdatum  = bestellijst.Select(a => a.Vertrekdatum).ToArray();
                    double[]           ordertotalen    = new double[bestellijst.Count()];
                    Bestellingstatus[] bestelstatussen = new Bestellingstatus[bestellijst.Count()];

                    for (int i = 0; i < bestellijst.Count(); i++)
                    {
                        double ordertotaal = 0;
                        IEnumerable <tblBestellijn> bestellijnen = bestellingservice.getBestellijnenByBestelling(bestellijst.ElementAt(i));
                        for (int j = 0; j < bestellijnen.Count(); j++)
                        {
                            tblProduct product = productservice.getProduct(bestellijnen.ElementAt(j).ProductID);
                            ordertotaal += productservice.getPrijs(product);
                        }
                        ordertotalen[i] = ordertotaal;
                        Bestellingstatus status = Bestellingstatus.InBewerking;
                        if (bestellijst.ElementAt(i).Geannuleerd == 1)
                        {
                            status = Bestellingstatus.Geannuleerd;
                        }
                        else
                        {
                            if (bestellijst.ElementAt(i).Vertrekdatum <= DateTime.Today)
                            {
                                status = Bestellingstatus.Voltooid;
                            }
                            else
                            {
                                status = Bestellingstatus.InBewerking;
                            }
                        }
                        bestelstatussen[i] = status;
                    }
                    vm.ordertotaal = ordertotalen;
                    vm.status      = bestelstatussen;
                }
            }
            return(View(vm));
        }
 //Constructor
 public Bestelling(int id, Bestellingstatus status, Tafel tafel, List<BestellingsProduct> producten, DateTime tijd, Medewerker medewerker)
 {
     this.ID = id;
     this.Status = status;
     this.Tafel = tafel;
     this.Producten = producten;
     if (this.Producten == null)
         this.Producten = new List<BestellingsProduct>();
     this.Tijd = tijd;
     this.Medewerker = medewerker;
 }
 public static void BestellingStatusUpdate(int bestellingsid, Bestellingstatus status)
 {
     SqlCommand command = new SqlCommand("UPDATE BESTELLING SET status = @Status WHERE ID = @ID");
     command.Parameters.AddWithValue("Status", (int)status);
     command.Parameters.AddWithValue("ID", bestellingsid);
     DatabaseWriter(command);
     CloseConnection();
 }
 //Gebruikt om een tafel vrij te geven nadat de rekening betaald is
 public static int UpdateBestellingStatusVanTafel(Bestellingstatus status, int tafelid)
 {
     SqlCommand command = new SqlCommand(@"UPDATE BESTELLING SET status = @status, tijd_afhandeling = @tijdafhandeling WHERE tafel_id = @tafelid AND status != 5");
     command.Parameters.AddWithValue("status", (int)status);
     command.Parameters.AddWithValue("tijdafhandeling", DateTime.Now);
     command.Parameters.AddWithValue("tafelid", tafelid);
     return DatabaseWriter(command);
 }
 public Tafel(int tafelNummer, Bestellingstatus status, bool beschikbaar = true)
 {
     this.Beschikbaar = beschikbaar;
     this.Nummer = tafelNummer;
     this.Status = status;
 }