Пример #1
0
 //Lijst van bestellijnen per bestelling
 public IEnumerable <tblBestellijn> getBestellijnenByBestelling(tblBestelling bestelling)
 {
     using (var db = new VivesTGVEntities1())
     {
         return(db.tblBestellijn.Where(a => a.BestellingID == bestelling.BestellingID).ToList());
     }
 }
Пример #2
0
 //Schrijf nieuwe bestelling weg
 public int addBestelling(tblBestelling bestelling)
 {
     using (var db = new VivesTGVEntities1())
     {
         db.tblBestelling.Add(bestelling);
         db.SaveChanges();
         return(bestelling.BestellingID);
     }
 }
Пример #3
0
 public void bestellingAnnuleren(int id)
 {
     using (var db = new VivesTGVEntities1())
     {
         tblBestelling bestelling = getBestellingByID(id);
         bestelling.Geannuleerd     = 1;
         db.Entry(bestelling).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Пример #4
0
 //Lijst van bestellijnen per bestelling
 public IEnumerable <tblBestellijn> getBestellijnenByBestelling(tblBestelling bestelling)
 {
     if (bestellingDAO.getBestellingByID(bestelling.BestellingID) != null)//bestelling bestaat
     {
         return(bestellingDAO.getBestellijnenByBestelling(bestelling));
     }
     else
     {
         throw new Exception("Bestelling bestaat niet");
     }
 }
Пример #5
0
        public async Task <ActionResult> Index(WinkelmandViewModel vm)
        {
            tblBestellijnService  bestellijnservice  = new tblBestellijnService();
            tblBestellingService  bestellingservice  = new tblBestellingService();
            tblTreinplaatsService treinplaatsservice = new tblTreinplaatsService();
            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;

                    tblBestelling bestelling = new tblBestelling();
                    bestelling.GebruikersID = id;
                    bestelling.Vertrekdatum = vm.trajectdatum.FirstOrDefault();
                    bestelling.Besteldatum  = DateTime.Today;
                    bestelling.Geannuleerd  = 0;
                    int bestellingid = bestellingservice.addBestelling(bestelling);
                    List <tblBestellijn> bestellijnen = new List <tblBestellijn>();
                    for (int i = 0; i < vm.hotelIDs.Count(); i++)
                    {
                        tblBestellijn bestellijn = new tblBestellijn();
                        bestellijn.BestellingID = bestellingid;
                        tblProduct product = productservice.getProductByHotel(vm.hotelIDs[i]);
                        bestellijn.ProductID = product.ProductID;
                        int bestellijnID = bestellijnservice.addBestellijn(bestellijn);
                    }
                    for (int i = 0; i < vm.trajectenIDs.Count(); i++)
                    {
                        tblBestellijn bestellijn = new tblBestellijn();
                        bestellijn.BestellingID = bestellingid;
                        tblProduct product;

                        product = productservice.getProductByTraject(vm.trajectenIDs[i], vm.treinklassen[i]);


                        bestellijn.ProductID = product.ProductID;

                        int            bestellijnID = bestellijnservice.addBestellijn(bestellijn);
                        tblTreinplaats treinplaats  = new tblTreinplaats();
                        treinplaats.BestellijnID = bestellijnID;
                        treinplaats.Naam         = vm.trajectnamen[i];
                        treinplaats.Plaatsnummer = vm.treinplaats[i];
                        if (vm.treinklassen[i])
                        {
                            treinplaats.Treinklasse = 1;
                        }
                        else
                        {
                            treinplaats.Treinklasse = 0;
                        }

                        treinplaatsservice.addTreinplaats(treinplaats);
                    }

                    tblWinkelmandlijnService winkelmandlijnservice = new tblWinkelmandlijnService();
                    winkelmandlijnservice.clearWinkelmand(id);
                    string bericht = "Dit zijn de gegevens van uw bestelling<br/><br/> <table class='table'><thead> <tr><th> Beschrijving </th><th> Vertrekdatum </th><th> Naam reiziger </th><th> Prijs </th></tr></thead> ";
                    for (int i = 0; i < vm.trajectenIDs.Count(); i++)
                    {
                        string tablelijn = "<tr><td>Treinticket van " + vm.trajectvertrek[i] + " naar " + vm.trajectaankomst[i] + " treinplaats " + vm.treinplaats[i] + "</td><td>" + vm.trajectdatum[i].Date.ToShortDateString() + " </td><td>" + vm.trajectnamen[i] + " </td><td>€" + vm.trajectprijzen[i] + "</td> </tr>";
                        bericht += tablelijn;
                    }
                    for (int i = 0; i < vm.hotelIDs.Count(); i++)
                    {
                        string tablelijn = "<tr><td>Hotelboeking in " + vm.hotelnaam[i] + "</td><td>" + vm.hoteldatum[i].Date.ToShortDateString() + " </td><td>" + vm.hotelnamen[i] + " </td><td>€" + vm.hotelprijzen[i] + "</td> </tr>";
                        bericht += tablelijn;
                    }
                    bericht += "</table>";

                    var userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
                    await userManager.SendEmailAsync(id, "VivesTGV: Uw bestelling " + bestelling.BestellingID, bericht);
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Пример #6
0
 //Schrijf nieuwe bestelling weg
 public int addBestelling(tblBestelling bestelling)
 {
     return(bestellingDAO.addBestelling(bestelling));
 }