コード例 #1
0
        public ActionResult Bevestig(Klant klant)
        {
            System.Diagnostics.Debug.WriteLine("In Bevestig");
            try
            {
                if (!ModelState.IsValid)
                {
                    //var errors = ModelState.Values.SelectMany(v => v.Errors);
                    //foreach (var item in errors)
                    //{
                    //    System.Diagnostics.Debug.WriteLine("Error: " + item.ErrorMessage);
                    //}
                    //System.Diagnostics.Debug.WriteLine("Modelstate is not valid");
                    return RedirectToAction("Afrekenen", "WinkelWagen");
                }

                WinkelWagen ww = GetWinkelWagenFromSession();

                if (ww == null)
                    return RedirectToAction("Index", "Home");

                if (ww.Producten.Count == 0)
                    return RedirectToAction("Index", "Home");

                return View(klant);
            }
            catch (Exception)
            {
                return RedirectToAction("Index", "Home");
            }
        }
コード例 #2
0
        private void AddWithSoap(WinkelWagen winkelWagen, Klant klant)
        {
            SOAPService.SOAPService SoapService = new SOAPService.SOAPService();

            db.Klanten.Add(klant);

            Order order = new Order
            {
                klant = klant
            };

            var checklist = new List<int>();

            foreach (var item in winkelWagen.Producten)
            {
                if (!checklist.Contains(item.id))
                {
                    var aantal = 0;
                    foreach (var product in winkelWagen.Producten)
                    {
                        if (product.id == item.id)
                            aantal++;
                    }

                    System.Diagnostics.Debug.WriteLine("aantal: " + aantal);

                    db.Orderregels.Add(
                        new Orderregel
                        {
                            aantal = aantal,
                            product = db.Producten.Find(item.id),
                            order = order
                        }
                    );
                    checklist.Add(item.id);
                }
            }
            // GetAcceptGiro heeft de 30 seconden timer/vertraging
            order.uniekGetal = SoapService.GetAcceptGiro(klant.voornaam + " " + klant.achternaam, klant.adres, winkelWagen.Totaal());

            db.Orders.Add(order);
            db.SaveChanges();
        }
コード例 #3
0
        public ActionResult Succes(Klant klant)
        {
            System.Diagnostics.Debug.WriteLine("In Succes");
            try
            {
                WinkelWagen ww = GetWinkelWagenFromSession();
                if (ww == null)
                    return RedirectToAction("Index", "Home");

                if (ww.Producten.Count == 0)
                    return RedirectToAction("Index", "Home");

                if (!ModelState.IsValid)
                {
                    System.Diagnostics.Debug.WriteLine("Modelstate is not valid");
                    return View(false);
                }

                System.Threading.Thread thread = new System.Threading.Thread(() => AddWithSoap(ww, klant));
                thread.Start();

                Session["cart"] = new WinkelWagen();

                return View(true);
            }
            catch (Exception)
            {
                return View(false);
            }
        }