Beispiel #1
0
        static void Main(string[] args)
        {
            OrderManager orderManager = new OrderManager();

            orderManager.AddOrders();
            orderManager.UpdateOrders();

            //ProductManager productManager = new ProductManager();

            //productManager.AddColors();
            //productManager.AddSizes();
            //productManager.AddProductSizes();
        }
Beispiel #2
0
        public ActionResult AddOrder(List <Order> orders)
        {
            ViewBag.Books = bookManager.GetBookList(Active.active);

            List <BookModel> models = new List <BookModel>();

            foreach (Book book in ViewBag.Books)
            {
                models.Add(new BookModel(book));
            }

            ViewBag.Books = models;

            Customer user = ((AccessToken)Session["AccessToken"]).User;

            string quantity = Request.Form["OrderQuantity"];
            string isbn     = Request.Form["searchISBN"];
            int    qty      = 0;

            if (!int.TryParse(quantity, out qty))
            {
                ModelState.AddModelError("", "Quantity must be a number");
                return(View(orders));
            }

            if (ModelState.IsValid)
            {
                if (orderManager.AddOrders(user.CustomerID, isbn, qty))
                {
                    return(RedirectToAction("Orders"));
                }
                else
                {
                    ModelState.AddModelError("", "Order could not be completed");
                    return(View(orders));
                }
            }
            else
            {
                return(View(orders));
            }
        }