public IHttpActionResult GetProduct(Guid id) { ProductsQuery query = new ProductsQuery(); Product product = query.GetProduct(id); if (product == null) { return(NotFound()); } return(Ok(product)); }
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()); }
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()); }
public static Product GetProduct(int productId) { return(_query.GetProduct(productId)); }
public IEnumerable <Product> SearchByName(string name) { ProductsQuery query = new ProductsQuery(); return(query.GetProduct(name)); }