コード例 #1
0
        private async Task ValidateCategory(int id)
        {
            var Category = await EcomakRepository.GetCategoryAsync(id);

            if (Category == null)
            {
                throw new NotFoundItemException($"cannot found Category with id:{id}");
            }
        }
コード例 #2
0
        public async Task <Category> GetCategoryAsync(int id, bool showProducts)
        {
            var CategoryEntity = await CategoriesRepository.GetCategoryAsync(id, showProducts);

            if (CategoryEntity == null)
            {
                throw new NotFoundItemException("Category not found");
            }

            return(mapper.Map <Category>(CategoryEntity));
        }
コード例 #3
0
        private async Task ValidateTrUpdate(int id, int CategoryId, Tr EditTr)
        {
            var Category = await EcomakRepository.GetCategoryAsync(CategoryId);

            if (Category == null)
            {
                throw new NotFoundItemException($"CanNot found Category with id {CategoryId}");
            }

            var Tr = await EcomakRepository.GetTrAsync(id);

            if (Tr == null)
            {
                throw new NotFoundItemException($"CanNot found Category with id {id}");
            }
        }