public List <CartItem> ListCartItemByOrderId(long id) { var dao = new OrderDetailDao(); List <OrderDetailViewModel> listOrderDetail = dao.ListDetailByOrderId(id); List <CartItem> listCartItem = new List <CartItem>(); Product product = new Product(); CartItem cartItem = new CartItem(); foreach (var item in listOrderDetail) { product = new ProductDao().GetByID(item.ProductID); cartItem = new CartItem() { Product = product, Quantity = item.Quantity }; listCartItem.Add(cartItem); } return(listCartItem); }