Esempio n. 1
0
        public async Task <ActionResult> GetCategory(int id)
        {
            var category = await _categoryServices.GetCategoryAsync(id).ConfigureAwait(false);// _context.Categories.FindAsync(id);

            if (category == null)
            {
                return(NotFound());
            }

            return(Ok(category));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetByIdAsync(int id)
        {
            var category = await _categoryServices.GetCategoryAsync(id);

            if (category != null)
            {
                return(Ok(category));
            }
            return(Ok());
        }
Esempio n. 3
0
        public async Task <IActionResult> Get(Guid id)
        {
            try
            {
                var category = await _categoryServices.GetCategoryAsync(id);

                if (category is null)
                {
                    return(BadRequest("Not found"));
                }
                return(Ok(category));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(BadRequest());
            }
        }