public List <OrderViewModel> GetAllProductsInCart(Guid cartId)
        {
            List <Order> allOrders = new List <Order>();

            try { allOrders = _repository.GetAllOrders(); }
            catch {  }
            List <OrderViewModel> allProductsInCart = new List <OrderViewModel>();

            foreach (Order x in allOrders)
            {
                if (x.CartId == cartId)
                {
                    //OrderViewModel orderViewModel = _mapperClass.ConvertOrderToOrderViewModel(x, GetOrderById(x.OrderId), GetCartById(x.CartId));
                    OrderViewModel orderViewModel = _mapperClass.ConvertOrderToOrderViewModel(x);
                    orderViewModel.UserName     = _repository.GetUserById(x.UserId).Fname;
                    orderViewModel.LocationName = _repository.GetLocationById(x.LocationId).City;
                    orderViewModel.ProductName  = _repository.GetProductById(x.ProductId).Name;
                    orderViewModel.Total        = _repository.GetProductById(x.ProductId).Price;

                    allProductsInCart.Add(orderViewModel);
                }
            }

            return(allProductsInCart);
        }
Пример #2
0
        public List <OrderViewModel> GetUserOrderHistory(string s)
        {
            List <OrderViewModel> ovm = new List <OrderViewModel>();
            List <Order>          ol  = _repository.GetOrderListByUser(s);

            foreach (var o in ol)
            {
                ovm.Add(_mapperClass.ConvertOrderToOrderViewModel(o));
            }
            return(ovm);
        }