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

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

            return(Ok(product));
        }
示例#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());
        }
示例#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());
        }
示例#4
0
 public static Product GetProduct(int productId)
 {
     return(_query.GetProduct(productId));
 }
示例#5
0
        public IEnumerable <Product> SearchByName(string name)
        {
            ProductsQuery query = new ProductsQuery();

            return(query.GetProduct(name));
        }