コード例 #1
0
 public IActionResult Get()
 {
     try
     {
         return(Ok(_repository.GetAllProducts()));
     }
     catch (Exception exc)
     {
         _logger.LogError($"Failed to get products: {exc}");
         return(BadRequest("Failed to get products"));
     }
 }
コード例 #2
0
        public IActionResult Shop()
        {
            /* var results = _context.Products
             *  .OrderBy(p => p.Category)
             *  .ToList();
             * return View(); */

            /* var results = from p in _context.Products
             *             orderby p.Category
             *             select p;
             * return View(results.ToList()); */

            var results = _repository.GetAllProducts();

            return(View(results));
        }