Ejemplo n.º 1
0
        // 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);
            }
        }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 3
0
 public Product Get(Guid id)
 {
     return(productContext.GetProduct(id));
 }