Пример #1
0
        public void GettingAProduct()
        {
            var productId = 2;
            var product   = _service.GetProductById(productId);

            Assert.IsNotNull(product);
        }
        public async Task <IActionResult> GetProduct([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var product = _service.GetProductById(id);

            if (product == null)
            {
                return(NotFound());
            }

            return(Ok(product));
        }