Ejemplo n.º 1
0
        public ActionResult GetAllOrderItems(int id) //id: order id
        {
            var currentUser = UserManager.FindById(User.Identity.GetUserId());

            IEnumerable <Core.Entities.OrderItem> orderItems = _orderProcessingService.GetOrderItemsFromOrder(id);

            decimal total = 0;

            foreach (var item in orderItems)
            {
                //if (item.Product.DiscountId != null)
                //{
                //    int? dId = item.Product.DiscountId;
                //    var discount = GetDiscountById(dId);

                //    if (discount.ValueType == 0)
                //    {
                //        decimal rate = 1 - Convert.ToDecimal(discount.DiscountValue / 100.00);

                //        ViewBag.dicountAmt = rate;

                //        var newPrice = item.Product.UnitPrice * rate;
                //        total = total + newPrice * item.Quantity;
                //    }
                //    else
                //    {
                //        //Deal with flat amount discount
                //    }
                //}
                //else
                //{
                //    total = total + item.Product.UnitPrice * item.Quantity;
                //}

                total = total + item.Product.UnitPrice * item.Quantity;

                ViewBag.Total = total;
            }

            return(PartialView("_AllOrderItems", orderItems));
        }