public IActionResult Get(int id)
 {
     try
     {
         var search = new ProductSearch
         {
             Id = id
         };
         var result = _getProducts.Execute(search);
         return(Ok(result.First()));
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
示例#2
0
 // GET: Products
 public ActionResult Index(ProductSearch search = null)
 {
     try
     {
         var result = _get.Execute(search);
         return(View(result));
     }
     catch (Exception e)
     {
         TempData["error"] = "An error has occurred";
         return(View());
     }
 }
示例#3
0
        public IActionResult Index()
        {
            var viewmodel = _getProducts.Execute(new ProductSearch());

            return(View(viewmodel));
        }
        // GET: Products
        public ActionResult Index()
        {
            var products = _getProducts.Execute();

            return(View(products));
        }
 public IActionResult Index([FromQuery] ProductQuery productQuery)
 {
     return(View(_getProducts.Execute(productQuery)));
 }
示例#6
0
 public IActionResult Get([FromQuery] ProductSearch query)
 {
     return(Ok(_getCommand.Execute(query)));
 }