예제 #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));
        }
예제 #2
0
        public async Task <IActionResult> GetByIdAsync(int id)
        {
            var category = await _categoryServices.GetCategoryAsync(id);

            if (category != null)
            {
                return(Ok(category));
            }
            return(Ok());
        }
예제 #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());
            }
        }