Exemple #1
0
        public async Task <ActionResult <Consumptie> > PostConsumptie(Consumptie consumptie)
        {
            _context.Consumptie.Add(consumptie);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetConsumptie", new { id = consumptie.Id }, consumptie));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Naam,Beschrijving,Prijs,CategoryId,MenuId")] Consumptie consumptie)
        {
            if (id != consumptie.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(consumptie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsumptieExists(consumptie.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", consumptie.CategoryId);
            return(View(consumptie));
        }
Exemple #3
0
        public async Task <IActionResult> PutConsumptie(int id, Consumptie consumptie)
        {
            if (id != consumptie.Id)
            {
                return(BadRequest());
            }

            _context.Entry(consumptie).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ConsumptieExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Archiveren(int?Id)
        {
            Bestelling res = await _context.Bestellingen.Where(x => x.Id == Id).FirstOrDefaultAsync();

            Consumptie y = await _context.Consumpties.Where(x => x.Id == res.ConsumptieId).FirstOrDefaultAsync();


            BestellingArchief archief = new BestellingArchief
            {
                TafelsId = res.TafelsId,
                Aantal   = res.Aantal,
                Bestellingsdatum_afgerond = res.Bestellingsdatum_afgerond,
                Bestellingsdatum_Tijd     = res.Bestellingsdatum_Tijd,
                Consumptie     = y.Naam,
                Archiveerdatum = DateTime.Now
            };

            //BestellingArchief bes = new BestellingArchief();
            //bes.TafelsId = res.TafelsId;
            //bes.Bestellingsdatum_afgerond = res.Bestellingsdatum_afgerond;
            //bes.Bestellingsdatum_Tijd = res.Bestellingsdatum_Tijd;
            //bes.Consumptie = y.Naam;
            //bes.Archiveerdatum = DateTime.Now;



            await _context.BestellingArchief.AddAsync(archief);

            await _context.SaveChangesAsync();

            _context.Bestellingen.Remove(res);
            await _context.SaveChangesAsync();

            return(RedirectToAction("AfgerondeBestellingen"));
        }
Exemple #5
0
        // GET: Chef/Menu/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var menu = await _context.Menus
                       .Include(cm => cm.ConsumptieMenu).ThenInclude(c => c.Consumptie)
                       .FirstOrDefaultAsync(m => m.Id == id);

            if (menu == null)
            {
                return(NotFound());
            }

            List <ConsumptieMenu> consmenu = _context.ConsumptieMenu.Where(x => x.MenuId == id).ToList();
            List <Consumptie>     cons     = new List <Consumptie>();

            foreach (var item in consmenu)
            {
                Consumptie consumptie = new Consumptie();
                consumptie = _context.Consumpties.Where(x => x.Id == item.ConsumptieId).FirstOrDefault();
                cons.Add(consumptie);
            }
            ViewData["ConsumptieId"] = new SelectList(cons, "Id", "Naam");



            return(View(menu));
        }
        public async Task <IActionResult> Create(int[] Allergenen, [Bind("Id,Naam,Beschrijving,Prijs,CategoryId")] Consumptie consumptie)
        {
            List <ConsumptieAllergenen> lijst = new List <ConsumptieAllergenen>();

            foreach (var item in Allergenen)
            {
                ConsumptieAllergenen Consaller = new ConsumptieAllergenen();
                Consaller.AllergenenId = item;
                Consaller.ConsumptieId = consumptie.Id;
                lijst.Add(Consaller);
            }

            consumptie.ConsumptieAllergenen = lijst;

            if (ModelState.IsValid)
            {
                _context.Add(consumptie);
                Console.WriteLine("MENU ID : " + consumptie.Id);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["ConsumptieId"] = new SelectList(_context.Consumpties, "Id", "Id", consumptieMenu.ConsumptieId);
            //ViewData["MenuId"] = new SelectList(_context.Menus, "Id", "Id", consumptieMenu.MenuId);
            return(View(consumptie));
        }
 public void BestellingToevoegen(Rekening rekening, Consumptie consumptie)
 {
     Bestelling bestelling = findBestelling(rekening, consumptie);
     if (bestelling == null)
     {
         bestelling = new Bestelling(rekening, consumptie);
         ((ListStore)Model).AppendValues(bestelling.ToString(), bestelling);
     }
     else
     {
         bestelling.Aantal++;
         Model.SetValue(find(bestelling), 0, bestelling.ToString());
     }
 }
        public void ConsumptieAfrekenen(Rekening rekening, Consumptie consumptie)
        {
            rekening.Waarde += consumptie.Prijs;
            IDbTransaction transaction = connection.BeginTransaction();
            try {
                save(rekening);

                logAfrekening(rekening, consumptie);
                transaction.Commit();
                Commit();
            }
            catch(Exception ex) {
                transaction.Rollback();
                rekening.Waarde -= consumptie.Prijs;
                throw new RepositoryException("Kan consumptie '" + consumptie.Naam + "' niet afrekenen voor '" + rekening.Naam + "'.", ex);
            }
        }
        public void Delete(Consumptie consumptie)
        {
            if (consumptie.Id == 0)
            {
                throw new RepositoryException("Consumptie is ongeldig: " + consumptie);
            }

            IDbCommand command = connection.CreateCommand();
            command.CommandText = "DELETE FROM consumptie WHERE rowid = @id";
            command.AddParameter("@id", consumptie.Id);
            command.Prepare();

            if (command.ExecuteNonQuery() != 1)
            {
                throw new RepositoryException("Kan consumptie '" + consumptie.Naam + "' niet verwijderen.");
            }

            Commit();
        }
        public void Create(Consumptie consumptie)
        {
            if (!consumptie.Validate())
            {
                throw new RepositoryException("Consumptie is ongeldig: " + consumptie);
            }

            IDbCommand command = connection.CreateCommand();
            command.CommandText = "INSERT INTO consumptie (Naam, Prijs) VALUES (@naam, @prijs)";
            command.AddParameter("@naam", consumptie.Naam);
            command.AddParameter("@prijs", consumptie.Prijs);
            command.Prepare();

            if (command.ExecuteNonQuery() != 1)
            {
                throw new RepositoryException("Kan consumptie '" + consumptie.Naam + "' niet aanmaken.");
            }

            Commit();
        }
        public void Refresh(Consumptie[] consumpties)
        {
            uint columns = (uint)Math.Ceiling(Math.Sqrt((double)consumpties.Length));
            uint rows = (uint)Math.Floor(Math.Sqrt((double)consumpties.Length));
            table = new Table(rows, columns, true);
            Add(table);

            uint index = 0;
            foreach(var consumptie in consumpties) {
                ConsumptieWidget consumptieWidget = new ConsumptieWidget(consumptie);
                consumptieWidget.Clicked += handleConsumptieWidgetClicked;

                // Bereken consumptie widget posities
                uint thisColumn = index % columns;
                uint thisRow = (index - thisColumn) / columns;
                table.Attach(consumptieWidget, thisColumn, thisColumn + 1, thisRow, thisRow + 1);

                index++;
            }
        }
Exemple #12
0
        public static async Task KoppelAllergeen(ApplicationDbContext _context)
        {
            List <ConsumptieAllergenen> lijst     = new List <ConsumptieAllergenen>();
            ConsumptieAllergenen        Consaller = new ConsumptieAllergenen();

            Consaller.AllergenenId = 4;
            Consaller.ConsumptieId = 1;
            //aller.Allergenen = _context.Allergenen.FirstOrDefault();
            //aller.Consumptie = _context.Consumpties.FirstOrDefault();
            lijst.Add(Consaller);

            Consumptie cons = new Consumptie();

            cons.Naam = "Spaghetti";
            cons.ConsumptieAllergenen = lijst;
            cons.Beschrijving         = "Spaghetti Bolgnese";
            cons.Prijs      = 6.50;
            cons.CategoryId = 4;
            _context.AddRange(cons);
            _context.SaveChanges();
        }
Exemple #13
0
        public static async Task KoppelMenu(ApplicationDbContext _context)
        {
            List <ConsumptieMenu> test = new List <ConsumptieMenu>();
            ConsumptieMenu        menu = new ConsumptieMenu();

            menu.ConsumptieId = 2;
            menu.MenuId       = 2;
            //aller.Allergenen = _context.Allergenen.FirstOrDefault();
            //aller.Consumptie = _context.Consumpties.FirstOrDefault();
            test.Add(menu);

            Consumptie consumptie = new Consumptie();

            consumptie.ConsumptieMenu = test;
            consumptie.CategoryId     = 1;
            consumptie.Beschrijving   = "tset";
            consumptie.Naam           = "test";
            consumptie.Prijs          = 1.5;


            _context.Consumpties.Add(consumptie);
            await _context.SaveChangesAsync();
        }
Exemple #14
0
        public IActionResult Index()
        {
            Sys.CheckAccount(_context, _usermanager, _signmanager, User.Identity.Name).Wait();

            //Alle specifieke item voor de gepaste rol
            Dashboard dash = new Dashboard();

            if (User.IsInRole("Manager"))
            {
                dash.users         = _context.Klanten.Where(x => x.Rol.Name == "Klant").ToList();
                dash.Reserveringen = _context.Reserveringen.Where(x => x.ReserveringsDatum == DateTime.Today).ToList();
                dash.Tafels        = _context.Tafels.Where(x => x.Bezet == false).ToList();
                //Omzet berekenen door afgeronden bestellingen en archief
                double                   Omzet        = 0.0;
                List <Bestelling>        bestellingen = _context.Bestellingen.Where(x => x.Afgerond == true).ToList();
                List <BestellingArchief> archief      = _context.BestellingArchief.ToList();

                Console.WriteLine("\n\nItem count in bestelling afgerond : " + bestellingen.Count);
                Console.WriteLine("\n\nItem count in archief  : " + archief.Count);

                foreach (var item in bestellingen)
                {
                    Console.WriteLine("!! \n\nItems in bestelling : " + item.Aantal);
                    Consumptie cons = _context.Consumpties.Where(x => x.Id == item.ConsumptieId).First();

                    Omzet += cons.Prijs * item.Aantal;
                }
                foreach (var item in archief)
                {
                    Omzet += _context.Consumpties.Where(x => x.Naam == item.Consumptie).First().Prijs *item.Aantal;
                }
                dash.Omzet = Omzet;
            }

            return(View(dash));
        }
 public ConsumptieWidget(Consumptie consumptie)
 {
     this.consumptie = consumptie;
     Label = consumptie.ToStringMetPrijs();
 }
        private Consumptie readConsumptie(IDataReader dataReader)
        {
            Consumptie consumptie = new Consumptie();
            consumptie.Id = dataReader.GetInt32("rowid");
            consumptie.Naam = dataReader.GetString("Naam");
            consumptie.Prijs = dataReader.GetDecimal("Prijs");
            consumptie.Categorie = dataReader.GetString("Categorie");

            return consumptie;
        }
        public void Update(Consumptie consumptie)
        {
            if (consumptie.Id == 0)
            {
                throw new RepositoryException("Ongeldige consumptie.");
            }

            IDbCommand command = connection.CreateCommand();
            command.CommandText = "UPDATE consumptie SET naam = @naam, categorie = @categorie, prijs = @prijs WHERE rowid = @id";
            command.AddParameter("@naam", consumptie.Naam);
            command.AddParameter("@categorie", consumptie.Categorie);
            command.AddParameter("@prijs", consumptie.Prijs);
            command.AddParameter("@id", consumptie.Id);
            command.Prepare();

            command.ExecuteNonQuery();

            Commit();
        }
 void handleConsumptieWidgetClicked(object sender, EventArgs e)
 {
     GekozenConsumptie = ((ConsumptieWidget)sender).Consumptie;
     Destroy();
 }
Exemple #19
0
        public static async Task UpdateItems(ApplicationDbContext _context)
        {
            Console.WriteLine("Updating Items");
            List <Consumptie> check       = new List <Consumptie>();
            Consumptie        voorgerecht = new Consumptie
            {
                Naam         = "Tomaten soep",
                Beschrijving = "soep gemaakt van tomatten",
                Prijs        = 6.50,
                Category     = _context.Categories.Where(x => x.Naam == "Voorgerecht").First(),
            };
            Consumptie drinken = new Consumptie
            {
                Naam         = "Coca Cola",
                Beschrijving = "Cola",
                Prijs        = 2.50,
                Category     = _context.Categories.Where(x => x.Naam == "Drinken").First(),
            };

            check.Add(drinken);
            Consumptie nagerecht = new Consumptie
            {
                Naam         = "Dame blanche",
                Beschrijving = "ijs",
                Prijs        = 3.25,
                Category     = _context.Categories.Where(x => x.Naam == "Nagerecht").First(),
            };

            check.Add(nagerecht);
            Consumptie franseuiensoep = new Consumptie
            {
                Naam         = "Franse Uiensoep",
                Beschrijving = "Heerlijke soep gemaakt van franse uien",
                Prijs        = 6.50,
                Category     = _context.Categories.Where(x => x.Naam == "Voorgerecht").First(),
            };

            check.Add(franseuiensoep);
            Consumptie ratatouille = new Consumptie
            {
                Naam         = "Ratatouille",
                Beschrijving = "Menu met Ratatouille",
                Prijs        = 6.50,
                Category     = _context.Categories.Where(x => x.Naam == "Hoofdgerecht").First(),
            };

            check.Add(ratatouille);
            Consumptie moelleux = new Consumptie
            {
                Naam         = "Moelleux au chocolat",
                Beschrijving = "Heerlijke chocolade dessert",
                Prijs        = 6.50,
                Category     = _context.Categories.Where(x => x.Naam == "Nagerecht").First(),
            };

            check.Add(moelleux);
            Consumptie icetea = new Consumptie
            {
                Naam         = "Ice Tea",
                Beschrijving = "Ice Tea",
                Prijs        = 3.50,
                Category     = _context.Categories.Where(x => x.Naam == "Drinken").First(),
            };

            check.Add(icetea);
            Consumptie flam = new Consumptie
            {
                Naam         = "Elsässer Flammkuchen",
                Beschrijving = "Elsässer Flammkuchen",
                Prijs        = 7.50,
                Category     = _context.Categories.Where(x => x.Naam == "Hoofdgerecht").First(),
            };

            check.Add(flam);
            Consumptie boeuf = new Consumptie
            {
                Naam         = "Boeuf Bourguignon",
                Beschrijving = "iets wat lijkt op champion soep met vlees erin",
                Prijs        = 5.50,
                Category     = _context.Categories.Where(x => x.Naam == "Voorgerecht").First(),
            };
            Consumptie madeleines = new Consumptie
            {
                Naam         = "Madeleines",
                Beschrijving = "Franse koekies",
                Prijs        = 4.50,
                Category     = _context.Categories.Where(x => x.Naam == "Nagerecht").First(),
            };

            check.Add(madeleines);
            Consumptie chocolademelk = new Consumptie
            {
                Naam         = "Chocolade Melk",
                Beschrijving = "Warme chocolade melk met slageroom",
                Prijs        = 2.50,
                Category     = _context.Categories.Where(x => x.Naam == "Drinken").First(),
            };

            check.Add(chocolademelk);
            check.Add(boeuf);
            foreach (var item in check)
            {
                int i = _context.Consumpties.Where(x => x.Naam == item.Naam).Count();
                if (i == 0)
                {
                    _context.Consumpties.Add(item);
                }
            }
            await _context.SaveChangesAsync();
        }
        private Bestelling findBestelling(Rekening rekening, Consumptie consumptie)
        {
            TreeIter iter;
            Model.GetIterFirst(out iter);

            do
            {
                Bestelling bestelling = (Bestelling)Model.GetValue(iter, 1);
                if (bestelling != null && bestelling.Rekening.Equals(rekening) && bestelling.Consumptie.Equals(consumptie))
                {
                    return bestelling;
                }
            } while(Model.IterNext(ref iter));

            return null;
        }
        private void logAfrekening(Rekening rekening, Consumptie consumptie)
        {
            IDbCommand command = connection.CreateCommand();
            command.CommandText = "INSERT INTO consumptielog (rekeningid, rekeningnaam, consumptieid, consumptienaam, datum) VALUES (@rekeningId, @rekeningNaam, @consumptieId, @consumptieNaam, current_timestamp)";
            command.AddParameter("@rekeningId", rekening.Id);
            command.AddParameter("@rekeningNaam", rekening.Naam);
            command.AddParameter("@consumptieId", consumptie.Id);
            command.AddParameter("@consumptieNaam", consumptie.Naam);
            command.Prepare();

            if (command.ExecuteNonQuery() != 1)
            {
                throw new RepositoryException("Kan consumptie afrekening van '" + consumptie.Naam + "' niet loggen voor rekening '" + rekening.Naam + "'.");
            }
        }
 public ConsumptieCategorie(string naam, Consumptie[] consumpties)
 {
     this.Naam = naam;
     this.Consumpties = consumpties;
 }
 public Bestelling(Rekening rekening, Consumptie consumptie)
 {
     Rekening = rekening;
     Consumptie = consumptie;
     Aantal = 1;
 }