public void DeleteOrder(int id)
        {
            repository.Remove(id);

            // Notify all Staff that orders table was updated
            OrdersHub.NotifyOrdersUpdateToAllClient();
        }
        public bool UpdateOrder(Order order)
        {
            var result = repository.Update(order);

            // Notify all Staff that orders table was updated
            OrdersHub.NotifyOrdersUpdateToAllClient();

            return(result);
        }
Example #3
0
        public ActionResult Checkout([Bind(Include = "FirstName,LastName,Address,City,AreaCode,PhoneNumber")] Order order)
        {
            List <Item> cart = (List <Item>)Session["cart"];

            if (ModelState.IsValid)
            {
                order.OrderPlaced = DateTime.Now;
                decimal?total = 0m;
                decimal?l     = 0m;
                foreach (var item in cart)
                {
                    l      = item.Product.Price * item.Quantity;
                    total += l;
                }
                order.OrderTotal    = total;
                order.OrderComplete = false;

                ctx.Orders.Add(order);


                ctx.SaveChanges();

                foreach (var shoppingCartItem in cart)
                {
                    var orderDetail = new OrderDetail
                    {
                        Amount    = shoppingCartItem.Quantity,
                        Price     = shoppingCartItem.Product.Price,
                        ProductId = shoppingCartItem.Product.ProductId,
                        OrderId   = order.OrderId
                    };
                    ctx.OrderDetails.Add(orderDetail);
                }
                ctx.SaveChanges();
                OrdersHub.BroadcastData();
                Session["cart"] = null;
            }
            return(RedirectToAction("PaymentWithPaypal", "Payment"));
        }
Example #4
0
        public ViewResult Checkout(Cart cart, Order order)
        {
            if (cart.Lines.Count() == 0)
            {
                ModelState.AddModelError("", "Извините, ваша корзина пуста!");
            }

            if (ModelState.IsValid)
            {
                orderProcessor.ProcessOrder(cart, order);
                cart.Clear();

                // Notify all Staff that orders table was updated
                OrdersHub.NotifyOrdersUpdateToAllClient();

                return(View("Completed"));
            }
            else
            {
                return(View(order));
            }
        }