public async Task <CategoryViewModel> GetByIdAsync(Guid id)
        {
            var special = new CategorySpecial(id);

            var category = await GetAsync(special);

            return(category);
        }
        public async Task <List <Guid> > CheckExistsAsync(List <Guid> ids)
        {
            var special = new CategorySpecial(ids);

            var idExists = await _categoryRepository.SelectAsync(special, x => x.Id);

            return(idExists?.ToList());
        }
        public async Task <IReadOnlyList <CategoryItemViewModel> > GetAllActiveAsync()
        {
            var special    = new CategorySpecial(false);
            var categories = await _categoryRepository.SelectAsync(
                special,
                cat => _mapper.Map <CategoryItemViewModel>(cat),
                true);

            return(categories);
        }
        public async Task <bool> TrashAsync(string categoryUrl, string categoryCode, bool isDelete = true)
        {
            var special  = new CategorySpecial(categoryUrl, categoryCode);
            var category = await _categoryRepository.GetFirstOrDefaultAsync(special);

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

            category.Deleted = isDelete;
            var rows = _categoryRepository.Update(category);

            return(rows > 0);
        }
        public async Task <CategoryViewModel> GetAsync(string url, string code)
        {
            var special = new CategorySpecial(url, code);

            return(await GetAsync(special));
        }
 private async Task <CategoryViewModel> GetAsync(CategorySpecial special)
 {
     return(await _categoryRepository.SelectFirstOrDefaultAsync(
                special,
                category => _mapper.Map <CategoryEntity, CategoryViewModel>(category)));
 }