Exemple #1
0
        public IHttpActionResult GetProduct(Guid id)
        {
            ProductsQuery query   = new ProductsQuery();
            Product       product = query.GetProduct(id);

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

            return(Ok(product));
        }
Exemple #2
0
        public IHttpActionResult Delete(Guid id)
        {
            ProductsQuery query   = new ProductsQuery();
            Product       product = query.GetProduct(id);

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

            new DeleteProduct(product).Call();

            return(Ok());
        }
Exemple #3
0
        public IHttpActionResult Update(Guid id, [FromBody] Product product)
        {
            if (product == null || product.Id != id)
            {
                return(BadRequest());
            }

            ProductsQuery query           = new ProductsQuery();
            Product       originalProduct = query.GetProduct(id);

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

            new UpdateProduct(id, product).Call();

            return(Ok());
        }
Exemple #4
0
 public static Product GetProduct(int productId)
 {
     return(_query.GetProduct(productId));
 }
Exemple #5
0
        public IEnumerable <Product> SearchByName(string name)
        {
            ProductsQuery query = new ProductsQuery();

            return(query.GetProduct(name));
        }