Exemplo n.º 1
0
            public async Task <Response <int> > Handle(DeleteProductCategoryByIdCommand command, CancellationToken cancellationToken)
            {
                var category = await _productCategoryRepository.GetByIdAsync(command.Id);

                if (category == null)
                {
                    throw new ApiException($"Product Group Not Found.");
                }
                await _productCategoryRepository.DeleteAsync(category);

                await _unitOfWork.Commit(cancellationToken);

                return(new Response <int>(category.Id));
            }
            public async Task <Response <int> > Handle(DeleteProductCategoryByIdCommand command, CancellationToken cancellationToken)
            {
                var category = await _productCategoryRepository.GetByIdAsync(command.Id);

                if (category == null)
                {
                    throw new ApiException($"Product category Not Found.");
                }
                if (command.Physical)
                {
                    await _productCategoryRepository.DeleteAsync(category);
                }
                else //Update status IsDeleted
                {
                    category.IsDeleted = true;
                    await _productCategoryRepository.UpdateAsync(category);
                }

                await _unitOfWork.Commit(cancellationToken);

                return(new Response <int>(category.Id));
            }