public IActionResult Remove(long id, KlantLogin klantLogin)
        {
            ApplyLanguage();
            OnlineBestelLijn teVerwijderenBestelLijn = _onlineBestelLijnRepository.getOnlineBestellijn(id);
            IEnumerable <OnlineBestelLijn> lijstBestellijnen;

            if (teVerwijderenBestelLijn.HoofdProdBestelLijnId == 0)
            {
                lijstBestellijnen = _onlineBestelLijnRepository.getOnlineBestelLijnen(klantLogin)
                                    .Where(p => p.HoofdProdBestelLijnId == teVerwijderenBestelLijn.Id);
                _onlineBestelLijnRepository.verwijderOBestelLijn(teVerwijderenBestelLijn);
                if (lijstBestellijnen.Count() > 0)
                {
                    foreach (OnlineBestelLijn item in lijstBestellijnen)
                    {
                        _onlineBestelLijnRepository.verwijderOBestelLijn(item);
                    }
                }


                _onlineBestelLijnRepository.SaveChanges();
                TempData["message"] = "Artikels succesvol verwijderd";
            }
            else
            {
            }
            winkelMandje = this._onlineBestelLijnRepository.getOnlineBestelLijnen(klantLogin);
            totaalPrijs();
            return(View("Index", winkelMandje));
        }
Ejemplo n.º 2
0
        public IActionResult Details(int id, KlantLogin klantLogin)
        {
            Bestelling bestelling        = _bestellingRepo.getBestellingById(id, klantLogin);
            BestellingDetailViewModel vm = new BestellingDetailViewModel(bestelling);

            return(View(vm));
        }
 public IActionResult Index(KlantLogin klantLogin)
 {
     winkelMandje = this._onlineBestelLijnRepository.getOnlineBestelLijnen(klantLogin);
     ApplyLanguage();
     totaalPrijs();
     return(View(winkelMandje));
 }
        private Decimal geefPrijsNaKorting(List <Product> geselecteerdeProducten, KlantLogin klantLogin)
        {
            Decimal prijs   = 0;
            Product product = geselecteerdeProducten.ElementAt(0);

            if (product.Typekorting == 1)
            {
                prijs = product.Prijs - product.Prijs * Convert.ToDecimal(klantLogin.Klant.Korting1) / 100;
            }
            else if (product.Typekorting == 2)
            {
                prijs = product.Prijs - product.Prijs * Convert.ToDecimal(klantLogin.Klant.Korting2) / 100;
            }

            for (int i = 1; i < geselecteerdeProducten.Count; i++)
            {
                product = geselecteerdeProducten.ElementAt(i);
                if (product.Typekorting == 1)
                {
                    prijs = prijs + product.PrijsGekoppeld - product.PrijsGekoppeld * Convert.ToDecimal(klantLogin.Klant.Korting1) / 100;
                }
                else if (product.Typekorting == 2)
                {
                    prijs = prijs + product.PrijsGekoppeld - product.PrijsGekoppeld * Convert.ToDecimal(klantLogin.Klant.Korting2) / 100;
                }
            }

            return(prijs);
        }
        public IActionResult Details(long Id, KlantLogin klantLogin)
        {
            ApplyLanguage();
            List <Product> geselecteerdeProducten = new List <Product>();

            ProductDetailViewModel vm;
            Product prod = this._productRepo.getProductById(Id);

            if (!geselecteerdeProducten.Contains(prod))
            {
                geselecteerdeProducten.Add(prod);
            }
            vm = voegVasteProductenToe(geselecteerdeProducten, prod.gekoppeldProductenLijst(), 0, klantLogin);

            ViewData["NormalePrijs"]   = geefPrijs(geselecteerdeProducten);
            ViewData["PrijsNaKorting"] = geefPrijsNaKorting(geselecteerdeProducten, klantLogin);

            ViewData["Stock"] = geefStockWaarde(geselecteerdeProducten.ElementAt(0));
            List <int> lijst = new List <int>();

            for (int i = 1; i < 100; i++)
            {
                lijst.Add(i);
            }
            ViewData["aantal"] = new SelectList(lijst);

            return(View(vm));
        }
Ejemplo n.º 6
0
        public IActionResult BeheerAccount(KlantLogin klantLogin)
        {
            string taal  = "";
            Klant  klant = klantLogin.Klant;

            switch (klantLogin.Taal)
            {
            case 1:
                taal = "nl";
                break;

            case 2:
                taal = "en";
                break;

            case 3:
                taal = "fr";
                break;
            }
            AccountViewModel vm    = new AccountViewModel(klant, taal);
            List <string>    talen = new List <string>();

            talen.Add("nl");
            talen.Add("en");
            talen.Add("fr");
            ViewData["talen"] = new SelectList(talen);
            ApplyLanguage();
            return(View(vm));
        }
        public IActionResult GeefBestellingDetail(long id, KlantLogin klantLogin)
        {
            ApplyLanguage();
            Bestelling bestelling        = _bestellingRepo.getBestellingById(id, klantLogin);
            BestellingDetailViewModel vm = new BestellingDetailViewModel(bestelling);

            return(View(vm));
        }
        public IActionResult GeefOrders(KlantLogin klantLogin)
        {
            ApplyLanguage();
            List <Bestelling> bestellingen = _bestellingRepo.getBestellingen(klantLogin);
            IEnumerable <OnlineBestelling> onlinebestellingen = _onlineBestellingRepository.getOnlineBestellingen(klantLogin);
            BestellingViewModel            vm = new BestellingViewModel(null, onlinebestellingen);

            return(View(vm));
        }
        public IActionResult MaakOrder(string id, KlantLogin klantLogin)
        {
            ApplyLanguage();
            List <Transport> lijstTransportTypes = _transportRepository.getAllTransport();
            List <Klant>     leverKlanten        = GetLijstLeverklanten(klantLogin);

            MaakOrderViewModel vm = new MaakOrderViewModel(leverKlanten, leverKlanten.ElementAt(0), "", "", lijstTransportTypes, lijstTransportTypes.ElementAt(0));

            return(View(vm));
        }
      public IActionResult Index(KlantLogin klantLogin)
      {
          //List<FactuurLijn> factuurlijn = _factuurLijnRepository.getFactuurLijnen();
          List <Factuur>   facturen = _factuurRepository.getFacturen(klantLogin);
          FactuurViewModel vm       = new FactuurViewModel(facturen);
          decimal          prijs    = 0;

          ApplyLanguage();
          return(View(vm));
      }
      public IActionResult Details(int id, KlantLogin klantLogin)
      {
          Factuur factuur = _factuurRepository.getFactuur(id, klantLogin);

          ApplyLanguage();

          FactuurDetailViewModel vm = new FactuurDetailViewModel(factuur);

          return(View(vm));
      }
        public IActionResult GeefOnlineOrderDetails(long id, KlantLogin klantLogin)
        {
            OnlineBestelling onlineBestelling = _onlineBestellingRepository.getOnlineBestellingById(id, klantLogin);

            ApplyLanguage();
            var    request = HttpContext.Features.Get <IRequestCultureFeature>();
            string taal    = request.RequestCulture.Culture.Name;
            OnlineBestellingDetailViewModel vm = new OnlineBestellingDetailViewModel(onlineBestelling, taal);

            return(View(vm));
        }
        public List <Klant> GetLijstLeverklanten(KlantLogin klantLogin)
        {
            List <Klant> leverKlanten = new List <Klant>();

            leverKlanten.Add(klantLogin.Klant);
            foreach (KlantKoppeling klantKoppeling in klantLogin.Klant.KlantKoppelingen)
            {
                leverKlanten.Add(klantKoppeling.GekoppeldKlant);
            }
            return(leverKlanten);
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> LogInAsync(string gebruikersnaam, string wachtwoord)
        {
            var        request          = HttpContext.Features.Get <IRequestCultureFeature>();
            string     taal             = request.RequestCulture.Culture.Name;
            string     lg_psw_encrypted = Encryption.Encrypt(wachtwoord, "dst.be rules");
            KlantLogin kl = _loginRepo.getLoginByGebruikersNaam(gebruikersnaam);

            ApplyLanguage();

            if (lg_psw_encrypted.Equals(kl.Paswoord))
            {
                TempData["Message"] = "You have successfully logged in";
            }
            else
            {
                TempData["error"] = "Username and Password do not match";
                return(View());
            }

            //Verificatie komt hier
            KlantLogin klant = _loginRepo.getLoginByGebruikersNaam(gebruikersnaam);

            var claims = new List <Claim>
            {
                new Claim(ClaimTypes.Name, klant.Voornaam + " " + klant.Naam),
                new Claim(ClaimTypes.NameIdentifier, klant.Id.ToString()),
                new Claim(ClaimTypes.Role, "Administrator"),
            };

            var identityy = new ClaimsIdentity(claims, "rechten");

            var userPrincipal = new ClaimsPrincipal(new[] { identityy });

            await HttpContext.SignInAsync(userPrincipal);

            switch (kl.Taal)
            {
            case 1:
                taal = "nl";
                break;

            case 2:
                taal = "en";
                break;

            case 3:
                taal = "fr";
                break;
            }
            veranderTaal(taal);

            return(RedirectToAction("Index", "Product"));
        }
        public IActionResult GeefOrders(KlantLogin klantLogin, string?productNaam, DateTime?vanDatum, DateTime?totDatum
                                        , string?leverAdres, byte?geleverd)
        {
            if (productNaam == null && vanDatum == null && totDatum == null &&
                leverAdres == null && geleverd == null)
            {
                return(RedirectToAction("GeefOrders"));
            }
            List <Bestelling> bestellingen = _bestellingRepo.getBestellingenByFilter(klantLogin, productNaam, vanDatum, totDatum, leverAdres, geleverd);
            IEnumerable <OnlineBestelling> onlinebestellingen = _onlineBestellingRepository.getOnlineBestellingen(klantLogin);
            BestellingViewModel            vm = new BestellingViewModel(bestellingen, onlinebestellingen);

            ApplyLanguage();
            return(View(vm));
        }
      public IActionResult Index(string?productNaam, long?factuurNr, DateTime?vanDatum, DateTime?totDatum
                                 , long?zendNotaNr, string?serienummer, KlantLogin klantLogin)
      {
          //List<FactuurLijn> factuurlijn = _factuurLijnRepository.getFactuurLijnen();
          List <Factuur>   facturen = _factuurRepository.getGefilterdeFactuur(productNaam, factuurNr, vanDatum, totDatum, zendNotaNr, serienummer, klantLogin);
          FactuurViewModel vm       = new FactuurViewModel(facturen);

          ApplyLanguage();

          vm.ProductNaam = productNaam;
          vm.FactuurNr   = factuurNr;
          vm.VanDatum    = vanDatum;
          vm.TotDatum    = totDatum;
          vm.ZendNotaNr  = zendNotaNr;
          vm.Serienummer = serienummer;
          return(View(vm));
      }
        public List <Bestelling> getBestellingenByFilter(KlantLogin klantLogin, string?productNaam, DateTime?vanDatum, DateTime?totDatum, string?leverAdres, byte?geleverd)
        {
            List <Bestelling> bestellingen = new List <Bestelling>();

            if (productNaam != null)
            {
                foreach (Bestelling bestelling in getBestellingen(klantLogin))
                {
                    foreach (BestelLijn bestelLijn in bestelling.Bestelijnen)
                    {
                        if (bestelLijn.ProductOmschrijving.Contains(productNaam))
                        {
                            bestellingen.Add(bestelling);
                        }
                    }
                }
            }
            else
            {
                bestellingen = getBestellingen(klantLogin);
            }
            if (vanDatum != null)
            {
                bestellingen = bestellingen.Where(m => m.Datum > vanDatum).ToList();
            }

            if (totDatum != null)
            {
                bestellingen = bestellingen.Where(m => m.Datum < totDatum).ToList();
            }

            if (geleverd != null || geleverd == 3)
            {
                if (geleverd == 1)
                {
                    bestellingen = bestellingen.Where(m => m.Afgewerkt == 0).ToList();
                }
                else if (geleverd == 2)
                {
                    bestellingen = bestellingen.Where(m => m.Afgewerkt == 1).ToList();
                }
            }
            return(bestellingen);
        }
 public Bestelling getBestellingById(long id, KlantLogin klantLogin)
 {
     return(getBestellingen(klantLogin).Where(p => p.Id == id && p.Klant == klantLogin.Klant).SingleOrDefault());
 }
 public List <Bestelling> getBestellingen(KlantLogin klantLogin)
 {
     return(_bestellingen.Include(m => m.Bestelijnen).ThenInclude(m => m.Product).Include(m => m.Klant).Where(m => m.Klant == klantLogin.Klant).OrderByDescending(m => m.Datum).ToList());
 }
        public IActionResult Wijzig(string selectedProds, List <long>?productId, string?quantity, KlantLogin klantLogin)
        {
            ApplyLanguage();
            List <string>          stringSelectedValues = selectedProds.Split(",").ToList();
            List <Product>         geselecteerdeProducten;
            Product                hoofdProduct;
            ProductDetailViewModel vm;
            int index  = Convert.ToInt32(stringSelectedValues.ElementAt(0));
            int aantal = Convert.ToInt32(quantity);

            stringSelectedValues.RemoveAt(0);
            try
            {
                geselecteerdeProducten = wijzigSelectie(selectedProds, productId);
            }
            catch (ArgumentException ex)
            {
                geselecteerdeProducten = new List <Product>();
                foreach (string stringID in stringSelectedValues)
                {
                    geselecteerdeProducten.Add(_productRepo.getProductById(Convert.ToInt64(stringID)));
                }
                TempData["error"] = ex.Message;
            }

            hoofdProduct = this._productRepo.getProductById(geselecteerdeProducten.ElementAt(0).Id);
            vm           = new ProductDetailViewModel(geselecteerdeProducten, hoofdProduct.gekoppeldProductenLijst(), index, aantal, klantLogin.Klant);


            ViewData["NormalePrijs"]   = geefPrijs(geselecteerdeProducten) * aantal;
            ViewData["PrijsNaKorting"] = geefPrijsNaKorting(geselecteerdeProducten, klantLogin) * aantal;

            ViewData["Stock"] = geselecteerdeProducten.ElementAt(0).Stock;
            List <int> lijst = new List <int>();

            for (int i = 1; i < 100; i++)
            {
                lijst.Add(i);
            }
            ViewData["aantal"] = new SelectList(lijst);
            return(View("Details", vm));
        }
        public IActionResult PlaatsInWinkelmand(string selectedProds, List <long>?productId, string?quantity, KlantLogin klantLogin)
        {
            List <string>          stringSelectedValues = selectedProds.Split(",").ToList();
            List <Product>         geselecteerdeProducten;
            Product                hoofdProduct;
            ProductDetailViewModel vm;
            int index  = Convert.ToInt32(stringSelectedValues.ElementAt(0));
            int aantal = Convert.ToInt32(quantity);
            List <OnlineBestelLijn> lijstOnlineBestelLijn = new List <OnlineBestelLijn>();

            stringSelectedValues.RemoveAt(0);
            try
            {
                geselecteerdeProducten = wijzigSelectie(selectedProds, productId);
            }
            catch (ArgumentException ex)
            {
                geselecteerdeProducten = new List <Product>();
                foreach (string stringID in stringSelectedValues)
                {
                    geselecteerdeProducten.Add(_productRepo.getProductById(Convert.ToInt64(stringID)));
                }
                TempData["error"] = ex.Message;

                hoofdProduct = this._productRepo.getProductById(geselecteerdeProducten.ElementAt(0).Id);
                vm           = new ProductDetailViewModel(geselecteerdeProducten, hoofdProduct.gekoppeldProductenLijst(), index, aantal, klantLogin.Klant);


                ViewData["NormalePrijs"]   = geefPrijs(geselecteerdeProducten) * aantal;
                ViewData["PrijsNaKorting"] = geefPrijsNaKorting(geselecteerdeProducten, klantLogin) * aantal;

                /// ViewData["Stock"] = geselecteerdeProducten.ElementAt(0).Stock;

                return(View("Details", vm));
            }
            var    request = HttpContext.Features.Get <IRequestCultureFeature>();
            string taal    = request.RequestCulture.Culture.Name;

            try
            {
                if (aantal < 1)
                {
                    if (taal == "en")
                    {
                        throw new ArgumentException("Please enter a number higher than 0");
                    }
                    else if (taal == "fr")
                    {
                        throw new ArgumentException("Veuillez saisir un nombre supérieur à 0");
                    }
                    else
                    {
                        throw new ArgumentException("Gelieve een getal hoger dan 0 te geven");
                    }
                }
            }
            catch (ArgumentException ex)
            {
                TempData["error"] = ex.Message;

                hoofdProduct = this._productRepo.getProductById(geselecteerdeProducten.ElementAt(0).Id);
                vm           = new ProductDetailViewModel(geselecteerdeProducten, hoofdProduct.gekoppeldProductenLijst(), index, aantal, klantLogin.Klant);


                ViewData["NormalePrijs"] = geefPrijsNaKorting(geselecteerdeProducten, klantLogin) * aantal;
                //TempData["PrijsNaKorting"];

                ViewData["Stock"] = geselecteerdeProducten.ElementAt(0).Stock;

                return(View("Details", vm));
            }

            hoofdProduct = this._productRepo.getProductById(geselecteerdeProducten.ElementAt(0).Id);

            geselecteerdeProducten.RemoveAt(0);

            //get klant en klantLogin
            Klant klant = klantLogin.Klant;

            decimal prijs = 0;

            if (hoofdProduct.Typekorting == 1)
            {
                prijs = hoofdProduct.Prijs - hoofdProduct.Prijs * Convert.ToDecimal(klantLogin.Klant.Korting1) / 100;
            }
            else if (hoofdProduct.Typekorting == 2)
            {
                prijs = hoofdProduct.Prijs - hoofdProduct.Prijs * Convert.ToDecimal(klantLogin.Klant.Korting2) / 100;
            }
            OnlineBestelLijn onlineBestelLijn = new OnlineBestelLijn(0, klantLogin, klant, hoofdProduct, aantal, prijs, hoofdProduct.BtwPerc, DateTime.Now, 0);

            _onlineBestelLijnRepo.voegOnlineBestelLijnToe(onlineBestelLijn);
            _onlineBestelLijnRepo.SaveChanges();
            if (geselecteerdeProducten.Count() == 0)
            {
            }
            else
            {
                foreach (Product koppelProduct in geselecteerdeProducten)
                {
                    if (koppelProduct.Typekorting == 1)
                    {
                        prijs = koppelProduct.PrijsGekoppeld - koppelProduct.PrijsGekoppeld * Convert.ToDecimal(klantLogin.Klant.Korting1) / 100;
                    }
                    else if (koppelProduct.Typekorting == 2)
                    {
                        prijs = koppelProduct.PrijsGekoppeld - koppelProduct.PrijsGekoppeld * Convert.ToDecimal(klantLogin.Klant.Korting2) / 100;
                    }
                    lijstOnlineBestelLijn.Add(new OnlineBestelLijn(0, klantLogin, klant, koppelProduct, aantal, prijs, koppelProduct.BtwPerc, DateTime.Now, onlineBestelLijn.Id));
                }
                _onlineBestelLijnRepo.voegOnlineBestelLijnenToe(lijstOnlineBestelLijn);

                _onlineBestelLijnRepo.SaveChanges();
            }

            if (taal == "en")
            {
                TempData["message"] = "Succesful Add To Cart";
            }
            else if (taal == "fr")
            {
                TempData["message"] = "Produit placé avec succès dans le panier";
            }
            else
            {
                TempData["message"] = "Product succesvol geplaatst in het winkelwagen";
            }
            return(RedirectToAction("Index", "Order"));
        }
        public ProductDetailViewModel voegVasteProductenToe(List <Product> geselecteerdeProducten, List <List <ProductKoppeling> > productKoppelingen, int index, KlantLogin klantLogin)
        {
            ProductDetailViewModel vm;

            foreach (List <ProductKoppeling> lijst in productKoppelingen)
            {
                if (lijst.ElementAt(0).KoppelType.Id == 1)
                {
                    foreach (ProductKoppeling productKoppeling in lijst)
                    {
                        geselecteerdeProducten.Add(productKoppeling.GekoppeldProduct);
                    }
                }
            }
            vm = new ProductDetailViewModel(geselecteerdeProducten, productKoppelingen, index, 1, klantLogin.Klant);
            return(vm);
        }
 public List <Factuur> getFacturen(KlantLogin klantLogin)
 {
     return(_facturen.Include(m => m.FactuurLijnen).Include(m => m.Klant).Where(m => m.Klant == klantLogin.Klant).ToList());
 }
 public Factuur getFactuur(long id, KlantLogin klantLogin)
 {
     return(getFacturen(klantLogin).SingleOrDefault(m => m.Id == id));
 }
        public List <Factuur> getGefilterdeFactuur(string?productNaam, long?factuurNr, DateTime?vanDatum, DateTime?totDatum, long?zendNotaNr, string serienummer, KlantLogin klantLogin)
        {
            List <Factuur> facturen           = getFacturen(klantLogin).ToList();
            List <Factuur> gefilterdeFacturen = new List <Factuur>();

            if (productNaam != null)
            {
                if (!productNaam.Equals(""))
                {
                    foreach (Factuur item in facturen)
                    {
                        foreach (FactuurLijn lijn in item.FactuurLijnen)
                        {
                            if (lijn.ProductOmschrijving != null)
                            {
                                if (lijn.ProductOmschrijving.ToUpper().Contains(productNaam.ToUpper()))
                                {
                                    gefilterdeFacturen.Add(item);
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    gefilterdeFacturen = facturen;
                }
            }
            else
            {
                gefilterdeFacturen = facturen;
            }

            if (factuurNr != null)
            {
                if (!factuurNr.Equals(""))
                {
                    gefilterdeFacturen = gefilterdeFacturen.Where(m => m.FactuurNummer == factuurNr).ToList();
                }
            }

            if (vanDatum != null)
            {
                gefilterdeFacturen = gefilterdeFacturen.Where(m => m.Datum >= vanDatum).ToList();
            }
            if (totDatum != null)
            {
                gefilterdeFacturen = gefilterdeFacturen.Where(m => m.Datum <= totDatum).ToList();
            }

            if (zendNotaNr != null)
            {
                if (zendNotaNr != 0)
                {
                    List <Factuur> filterHulp = new List <Factuur>();
                    foreach (Factuur factuur in gefilterdeFacturen)
                    {
                        foreach (FactuurLijn lijn in factuur.FactuurLijnen)
                        {
                            if (lijn.ZendNummer == zendNotaNr)
                            {
                                filterHulp.Add(factuur);
                                break;
                            }
                        }
                    }
                    gefilterdeFacturen = filterHulp;
                }
            }

            if (serienummer != null)
            {
                if (!serienummer.Equals(""))
                {
                    List <Factuur> filterHulp = new List <Factuur>();
                    foreach (Factuur factuur in gefilterdeFacturen)
                    {
                        foreach (FactuurLijn lijn in factuur.FactuurLijnen)
                        {
                            if (lijn.SerieNummer.Equals(serienummer))
                            {
                                filterHulp.Add(factuur);
                                break;
                            }
                        }
                    }
                    gefilterdeFacturen = filterHulp;
                }
            }
            return(gefilterdeFacturen);
        }
 public OnlineBestelling getOnlineBestellingById(long id, KlantLogin klantLogin)
 {
     return(getOnlineBestellingen(klantLogin).Where(m => m.Id == id).SingleOrDefault());
 }
Ejemplo n.º 27
0
        public IActionResult BeheerAccount(KlantLogin klantLogin, string taal, string?oudWachtwoord, string?nieuweWachtwoord, string?herhaalWachtwoord)
        {
            if (oudWachtwoord != null)
            {
                try
                {
                    string nieuweWachtwoordGehashed = "";
                    string oudWachtwoordGehashed    = Encryption.Encrypt(oudWachtwoord, "dst.be rules");
                    if (!klantLogin.Paswoord.Equals(oudWachtwoordGehashed))
                    {
                        throw new ArgumentException("Uw oud wachtwoord komt niet overeen");
                    }
                    if (!nieuweWachtwoord.Equals(herhaalWachtwoord))
                    {
                        throw new ArgumentException("Uw nieuwe wachtwoord komt niet over met de herhaal wachtwoord");
                    }
                    nieuweWachtwoordGehashed = Encryption.Encrypt(nieuweWachtwoord, "dst.be rules");
                    klantLogin.Paswoord      = nieuweWachtwoordGehashed;
                    _loginRepo.SaveChanges();
                    TempData["message"] = "Gegevens succesvol gewijzigd";
                }
                catch (ArgumentException ex)
                {
                    TempData["error"] = ex.Message;
                }
            }
            if (taal != null)
            {
                byte taalIndex = 0;
                try
                {
                    switch (taal)
                    {
                    case "nl":
                        taalIndex = 1;
                        break;

                    case "en":
                        taalIndex = 2;
                        break;

                    case "fr":
                        taalIndex = 3;
                        break;
                    }
                    klantLogin.Taal = taalIndex;
                    _loginRepo.SaveChanges();
                    veranderTaal(taal);
                    TempData["message"] = "Gegevens succesvol gewijzigd";
                }
                catch (ArgumentException ex)
                {
                    TempData["error"] = ex.Message;
                }
            }

            Klant klant = klantLogin.Klant;

            AccountViewModel vm = new AccountViewModel(klant, taal);

            ApplyLanguage();
            return(RedirectToAction("BeheerAccount"));
        }
        public IActionResult MaakOrder(string referentie, string opmerking, short transportTypeId, long leverKlantId, KlantLogin klantLogin)
        {
            ApplyLanguage();
            var    request = HttpContext.Features.Get <IRequestCultureFeature>();
            string taal    = request.RequestCulture.Culture.Name;

            try
            {
                if (leverKlantId == 0)
                {
                    if (taal == "en")
                    {
                        throw new ArgumentException("Please choose a delivery address");
                    }
                    else if (taal == "fr")
                    {
                        throw new ArgumentException("Veuillez choisir une adresse de livraison");
                    }
                    else
                    {
                        throw new ArgumentException("Gelieve een leveradres te kiezen");
                    }
                }
                if (transportTypeId == 0)
                {
                    if (taal == "en")
                    {
                        throw new ArgumentException("Please choose a transport Type");
                    }
                    else if (taal == "fr")
                    {
                        throw new ArgumentException("Veuillez choisir un type de transport");
                    }
                    else
                    {
                        throw new ArgumentException("Gelieve een transportType te kiezen");
                    }
                }
                Klant     leverKlant = this._klantRepository.getKlant(leverKlantId);
                Transport transport  = this._transportRepository.getTransportById(transportTypeId);
                List <OnlineBestelLijn> lijstBestelLijnen = this._onlineBestelLijnRepository.getOnlineBestelLijnen(klantLogin);
                OnlineBestelling        bestelling        = new OnlineBestelling(klantLogin.Klant, leverKlant, referentie, opmerking, transport, klantLogin, lijstBestelLijnen);
                this._onlineBestellingRepository.voegOnlineBestellingToe(bestelling);
                this._onlineBestellingRepository.SaveChanges();
                TempData["message"] = "Bestelling succesvol geplaatst";
                if (taal == "en")
                {
                    TempData["message"] = "Order placed successfully";
                }
                else if (taal == "fr")
                {
                    TempData["message"] = "Commande passée avec succès";
                }
                else
                {
                    TempData["message"] = "Bestelling succesvol geplaatst";
                }
                return(RedirectToAction("Index", "Product"));
            }
            catch (ArgumentException ex)
            {
                TempData["error"] = ex.Message;
                List <Transport>   lijstTransportTypes = _transportRepository.getAllTransport();
                List <Klant>       leverKlanten        = GetLijstLeverklanten(klantLogin);
                MaakOrderViewModel vm = new MaakOrderViewModel(leverKlanten, leverKlanten.ElementAt(0), referentie, opmerking, lijstTransportTypes, lijstTransportTypes.ElementAt(0));
                return(View("MaakOrder", vm));
            }
        }
        public IActionResult RemoveBestelLijn(long id, KlantLogin klantLogin)
        {
            ApplyLanguage();
            OnlineBestelLijn teVerwijderenBestelLijn = _onlineBestelLijnRepository.getOnlineBestellijn(id);
            long             onlineBestellingId      = teVerwijderenBestelLijn.BestellingId;
            OnlineBestelling onlineBestelling        = _onlineBestellingRepository.getOnlineBestellingById(onlineBestellingId, klantLogin);

            List <OnlineBestelLijn> lijstBestellijnen;

            var    request = HttpContext.Features.Get <IRequestCultureFeature>();
            string taal    = request.RequestCulture.Culture.Name;

            if (teVerwijderenBestelLijn.HoofdProdBestelLijnId == 0)
            {
                lijstBestellijnen = onlineBestelling.OnlineBesltelLijnen.Where(m => m.HoofdProdBestelLijnId == teVerwijderenBestelLijn.Id).ToList();
                _onlineBestelLijnRepository.verwijderOBestelLijn(teVerwijderenBestelLijn);
                if (lijstBestellijnen.Count() > 0)
                {
                    foreach (OnlineBestelLijn item in lijstBestellijnen)
                    {
                        _onlineBestelLijnRepository.verwijderOBestelLijn(item);
                    }
                }
                _onlineBestelLijnRepository.SaveChanges();
                if (onlineBestelling.OnlineBesltelLijnen.Count < 1 || onlineBestelling.OnlineBesltelLijnen == null)
                {
                    _onlineBestellingRepository.verwijderOnlineBestelling(onlineBestelling);
                    TempData["message"] = "";
                    _onlineBestelLijnRepository.SaveChanges();
                    if (taal == "en")
                    {
                        TempData["message"] = "Order deleted successfully";
                    }
                    else if (taal == "fr")
                    {
                        TempData["message"] = "Commande supprimée avec succès";
                    }
                    else
                    {
                        TempData["message"] = "Bestelling succesvol verwijderd";
                    }
                    return(RedirectToAction("GeefOrders"));
                }
            }
            else
            {
            }
            if (taal == "en")
            {
                TempData["message"] = "OrderLine deleted successfully";
            }
            else if (taal == "fr")
            {
                TempData["message"] = "Ligne de commande supprimée avec succès";
            }
            else
            {
                TempData["message"] = "Bestellings lijn succesvol verwijderdt";
            }
            return(RedirectToAction("GeefOnlineOrderDetails", new { id = onlineBestellingId }));
        }
 public IEnumerable <OnlineBestelling> getOnlineBestellingen(KlantLogin klantLogin)
 {
     return(_onlineBestellingen.Include(p => p.OnlineBesltelLijnen).ThenInclude(p => p.Product).Include(p => p.Klant).Include(t => t.LeverKlant).Include(p => p.Transport)
            .OrderByDescending(m => m.Datum).Where(m => m.KlantLogin == klantLogin).ToList());
 }