Ejemplo n.º 1
0
        public async Task <CategoryViewModel> GetByIdAsync(Guid id)
        {
            var special = new CategorySpecial(id);

            var category = await GetAsync(special);

            return(category);
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public async Task <CategoryViewModel> GetAsync(string url, string code)
        {
            var special = new CategorySpecial(url, code);

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