コード例 #1
0
        public IActionResult GetProduct(int id, bool includeSaleItems = false)
        {
            var productModel = _productInfoRepository.GetProductModel(id, includeSaleItems);

            if (productModel == null)
            {
                _logger.LogInformation($"Product model with id {id} was not found");
                return(NotFound());
            }
            if (includeSaleItems)
            {
                var result = Mapper.Map <ProductModelDto>(productModel);

                return(Ok(result));
            }
            else
            {
                var result = Mapper.Map <ProductModelWithoutProductDto>(productModel);

                return(Ok(result));
            }
        }