Пример #1
0
        public void AddOrder(string productName, int productQuantity, out string errorMessage)
        {
            int productId = products.GetProductId(productName, out string error);

            errorMessage = error;

            if (!string.IsNullOrEmpty(errorMessage))
            {
                return;
            }

            int userId = users.CurrentUserId;

            orders.AddOrder(userId, productId, productQuantity);
        }
Пример #2
0
        public ActionResult Create(
            [Bind(Include = "Id,ProductsName,ProductPrice,DatePurchaced,Category,Quantity,User_Id")]
            FormCollection form)
        {
            IEnumerable <Order> order = new List <Order>();

            if (ModelState.IsValid)
            {
                var session = (List <Cart>)Session["Carts"];
                order = BusinessLogic.MapCartToTher(session);
                _db.AddOrder(order);
                _db.Commit();
                return(RedirectToAction("Index"));
            }

            return(View(order));
        }