Пример #1
0
        public async Task <CartDto> GetCart()
        {
            var products = new List <ProductDto>();
            var cart     = await _repo.Get();

            foreach (var productId in cart.ProductIds)
            {
                var product = await _productsRepo.GetById(productId);

                if (product != null)
                {
                    products.Add(_mapper.Map <ProductDto>(product));
                }
            }

            var mappedCart = _mapper.Map <CartDto>(cart);

            mappedCart.Products = products;
            return(mappedCart);
        }
Пример #2
0
 public Task <Product> GetProductById(string id) => _repo.GetById(id);