public async Task <IHttpActionResult> GetAsync(int id)
        {
            var category = await _service.GetAsync(id);

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

            return(Ok(category));
        }
예제 #2
0
        private async Task <TransactionCategory> GetCategoryAsync(int?categoryId, string categoryName, TransactionType type)
        {
            TransactionCategory category = null;

            if (categoryId.HasValue)
            {
                category = await _categoriesService.GetAsync(categoryId.Value);
            }

            if (category == null && !string.IsNullOrEmpty(categoryName))
            {
                category = _categoriesService.GetCategory(categoryName, type);

                if (category == null)
                {
                    category = await _categoriesService.AddAsync(new TransactionCategory { Name = categoryName, Type = type });
                }
            }

            return(category);
        }