Exemple #1
0
        public async Task <bool> DeleteAsync(Guid id)
        {
            Category category = await categoryRepository.FindByIdAsync(id);

            if (category == null)
            {
                return(false);
            }
            return(await categoryRepository.DeleteAsync(category));
        }
Exemple #2
0
        public async Task <Unit> Handle(DeleteCategoryCommand request, CancellationToken cancellationToken)
        {
            if (request.ID <= 0)
            {
                throw new ValidationException($"{nameof(request.ID)} is invalid");
            }

            await _repository.DeleteAsync(request.ID, cancellationToken);

            return(Unit.Value);
        }
        public async Task DeleteAsync(CategoryId categoryId)
        {
            var exists = await _repository.ExistsAsync(categoryId);

            if (!exists)
            {
                throw new NotFoundException <CategoryId>(categoryId);
            }

            await _repository.DeleteAsync(categoryId);
        }
Exemple #4
0
        public async Task <ActionResult> Delete(int id)
        {
            await categoriesRepository.DeleteAsync(id);

            return(RedirectToAction("Index"));
        }
 public async Task DeleteAsync(int id, int userId)
 {
     await _categoriesRepository.DeleteAsync(id, userId);
 }