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));
        }
        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 void verwijderOBestelLijn(OnlineBestelLijn onlineBestelLijn)
 {
     this._onlineBestelLijnen.Remove(onlineBestelLijn);
 }
        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 void voegOnlineBestelLijnToe(OnlineBestelLijn onlineBestelLijn)
 {
     this._onlineBestelLijnen.Add(onlineBestelLijn);
 }