Example #1
0
        public APIGatewayProxyResponse UpdateProductStatus(string sku, int status)
        {
            Product updatedProduct = _context.Products.SingleOrDefault(p => p.Sku == sku);

            if (updatedProduct == null)
            {
                return new APIGatewayProxyResponse {
                           StatusCode = 404, Body = "Requested product could not be found"
                }
            }
            ;

            updatedProduct.Status = status;
            _context.Attach(updatedProduct);
            _context.Entry(updatedProduct).Property("status").IsModified = true;
            _context.SaveChanges();

            return(new TypedAPIGatewayProxyResponse <Product>(200, updatedProduct));
        }