Esempio n. 1
0
        /// <summary>
        /// get product details by id.
        /// </summary>
        /// <param name="id">product id</param>
        /// <returns></returns>
        public ProductDto GetProductById(int id)
        {
            Domain.Products.Model.Product product = _productRepository.GetProductById(id);

            if (product == null)
            {
                throw new InvalidOperationException();
            }

            ProductMapper modelMapper = new ProductMapper();
            ProductDto    projectDto  = modelMapper.DtoFrom(product);

            return(projectDto);
        }
Esempio n. 2
0
        /// <summary>
        /// get all products list.
        /// </summary>
        /// <returns></returns>
        public IList <ProductDto> GetProducts()
        {
            IList <Domain.Products.Model.Product> products = _productRepository.GetProducts();

            if (products == null)
            {
                throw new InvalidOperationException();
            }
            ProductMapper modelMapper = new ProductMapper();

            IList <ProductDto> productDtoList = new List <ProductDto>();

            foreach (Domain.Products.Model.Product product in products)
            {
                ProductDto productdto = modelMapper.DtoFrom(product);
                productDtoList.Add(productdto);
            }

            return(productDtoList);
        }