Пример #1
0
        public Boolean insertCartItems(List<string> itemIds, long OrderId)
        {
            try
            {
                foreach (string itemId in itemIds)
                {
                    //insert into Cart table
                    CartItem cart = new CartItem();
                    cart.ItemID = long.Parse(itemId);
                    cart.Quantity = 0;
                    cart.Price = 0;
                    cart.AppUserID = long.Parse(Session["AppUserID"].ToString());
                    cart.OrderID = OrderId;
                    cart.DateAdded = DateTime.Now;
                    //cart.IsOrdered = false;
                    cart.DateOrdered = Convert.ToDateTime("1 Jan 1900");

                    cart = new OrderService().InsertCart(cart);
                }

                return true;
            }
            catch (Exception exception)
            {
                return false;
            }
        }
Пример #2
0
        public JsonResult CreateNewOrder(Order order)
        {
            try
            {
                Order result = new OrderService().Insert(order);

                var orderResult = new { Result = true, OrderID = result.OrderID.ToString() };

                return Json(orderResult);
            }
            catch (Exception exception)
            {
                var orderResult = new { Result = false, OrderID = 0, ErrorMessage = FormatMessages.ErrorMessage("Error creating order.") };

                return Json(orderResult);
            }
        }
Пример #3
0
 public JsonResult GetItemsByCategoryID(long id)
 {
     List<Item> items = new OrderService().GetItemsByCategoryID(id);
     return Json(items);
 }
Пример #4
0
 public JsonResult getCartItemByOrderId(long id)
 {
     List<CartItem> cart = new OrderService().getCartItemsByOrderId(id);
     return Json(cart.Select(x => new { x.CartItemID, x.ItemID, x.Item.Name, x.Quantity, x.Price, x.AppUserID, x.DateAdded, x.IsOrdered, UnitPrice = x.Item.Price }));
 }
Пример #5
0
        public ActionResult ViewOrder(long id)
        {
            OrderViewModel orderViewModel = new OrderViewModel();

            //get order details
            Order order = new OrderService().getById(id);

            orderViewModel.Order = order;

            return View(orderViewModel);
        }