public IActionResult Get(string name)
        {
            _logger.Information($"Get product by name {name}.");

            using var ctx = new Models.awvmsqldbContext();
            var product = ctx.Products.SingleOrDefault(p => p.Name == name);

            if (product == null)
            {
                _logger.Information($"Product with name {name} not found.");
                return(NotFound());
            }

            var mapped = new
            {
                productId     = product.ProductId,
                name          = product.Name,
                productNumber = product.ProductNumber,
                sellEndDate   = product.SellEndDate,
                sellStartDate = product.SellStartDate,
                listPrice     = product.ListPrice,
                weight        = product.Weight,
                size          = product.Size
            };

            return(Ok(mapped));
        }
        public void Put(int id, ProductDto product)
        {
            _logger.Information($"Update product by id {id}.");

            using var ctx = new Models.awvmsqldbContext();
            var saved = ctx.Products.SingleOrDefault(p => p.ProductId == id);

            saved.Name = product.Name;
            saved.Size = product.Size;

            ctx.SaveChanges();
        }
        public IActionResult Delete(int id)
        {
            _logger.Information($"Delete product by id {id}.");

            using var ctx = new Models.awvmsqldbContext();
            var product = ctx.Products.SingleOrDefault(p => p.ProductId == id);

            if (product == null)
            {
                _logger.Information($"{id} not found.");
                return(NotFound());
            }

            ctx.Products.Remove(product);
            ctx.SaveChanges();

            return(Ok());
        }
        public IActionResult Get()
        {
            _logger.Information("Get all products");

            using (var ctx = new Models.awvmsqldbContext())
            {
                var products = ctx.Products.Select(p => new
                {
                    productId     = p.ProductId,
                    name          = p.Name,
                    productNumber = p.ProductNumber,
                    sellEndDate   = p.SellEndDate,
                    sellStartDate = p.SellStartDate,
                    listPrice     = p.ListPrice,
                    weight        = p.Weight,
                    size          = p.Size
                }).ToArray();

                return(Ok(products));
            }
        }