public CategoryModel Get(int id, int?page = null, int?count = null)
        {
            CategoryModel res = null;

            try
            {
                int?start = null;
                if (page != null && count != null && page > 0 && count >= 0)
                {
                    start = (page - 1) * count;
                }
                var category = _categoriesManager.Get(id); res = new CategoryModel()
                {
                    Total    = category.Total,
                    Products = _productsManager.Get(category, start, count)
                };
            }
            catch (Exception exc)
            {
                res = new CategoryModel()
                {
                    Total    = 0,
                    Products = null
                };
            }
            return(res);
        }
Beispiel #2
0
 public Product Get(int id)
 {
     try
     {
         return(_productManager.Get(id));
     }
     catch (Exception exc)
     {
         return(null);
     }
 }
 public IActionResult Get()
 {
     return(Ok(_productsManager.Get()));
 }