// GET api/product/{id} public Product Get(int id) { Product product = _repository.GetProduct(id); if (product == null) { throw new HttpResponseException( Request.CreateResponse(HttpStatusCode.NotFound)); } else { return(product); } }
public IActionResult GetProduct(Guid id) { try { var product = _context.GetProduct(id); if (product == null) { throw new Exception("Wrong Id! Product doesn't exist."); } else { return(Ok(product)); } } catch (Exception ex) { return(StatusCode(500, "Error: " + ex.Message)); } }
public Product Get(Guid id) { return(productContext.GetProduct(id)); }