Esempio n. 1
0
        public ProductDTO GetProductById(int productId)
        {
            ProductDTO productDTO    = null;
            var        prouctMapping = unitOfWork.ProductSiteMappingRepository.GetAll();

            var product = unitOfWork.ProductRepository.GetById(productId);

            if (product != null)
            {
                productDTO = ProductConvertor.ConvertToProductDto(product, prouctMapping.Where(p => p.ProductId == product.ProductId).FirstOrDefault().ProductMappingId);
            }
            return(productDTO);
        }
Esempio n. 2
0
        public List <ProductDTO> GetAllProducts()
        {
            List <ProductDTO> productList = new List <ProductDTO>();
            var products      = unitOfWork.ProductRepository.GetAll();
            var prouctMapping = unitOfWork.ProductSiteMappingRepository.GetAll();

            if (products != null)
            {
                foreach (var product in products)
                {
                    productList.Add(ProductConvertor.ConvertToProductDto(product, prouctMapping.Where(p => p.ProductId == product.ProductId).FirstOrDefault().ProductMappingId));
                }
            }

            return(productList);
        }