コード例 #1
0
        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));
        }
コード例 #2
0
        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 }));
        }
コード例 #3
0
        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 OnlineBestellingDetailViewModel(OnlineBestelling onlineBestelling, string taal)
 {
     this.onlineBestelling = onlineBestelling;
     this.Taal             = taal;
 }
コード例 #5
0
 public void verwijderOnlineBestelling(OnlineBestelling onlineBestelling)
 {
     _onlineBestellingen.Remove(onlineBestelling);
 }
コード例 #6
0
 public void voegOnlineBestellingToe(OnlineBestelling onlineBestelling)
 {
     this._onlineBestellingen.Add(onlineBestelling);
 }