public IHttpActionResult Delete(ProductRemoveCommand command)
        {
            var validator = command.Validate();

            if (!validator.IsValid)
            {
                return(HandleValidationFailure(validator.Errors));
            }

            return(HandleCallback(_productService.Remove(command)));
        }
        public bool Remove(ProductRemoveCommand command)
        {
            var removeAll = true;

            foreach (var productId in command.ProductsId)
            {
                var eRemovido = _productRepository.Remove(productId);
                removeAll = eRemovido ? removeAll : false;
            }
            return(removeAll);
        }
Beispiel #3
0
        public async Task <Unit> Handle(ProductRemoveCommand request, CancellationToken cancellationToken)
        {
            var product = await _repository.GetProductByIdAsync(request.Id);

            if (product == null)
            {
                throw new NotFoundDomainException(string.Format(ErrorMessagesResource.NotFoundError, DisplayNamesResource.Product));
            }

            _repository.RemoveProduct(product);

            return(Unit.Value);
        }
Beispiel #4
0
        public bool Remove(ProductRemoveCommand cmd)
        {
            var isRemovedAll = true;

            foreach (var productId in cmd.ProductIds)
            {
                var isRemoved = _repositoryProduct.Remove(productId);
                // Aqui poderia dar o tramento adequado, armazenado quais ids foram removidos
                // e quais não forma removidos (e buscar o porquê).
                // Como é somente um exemplo, vamos somente retornar false (que não foi totalmente concluído)
                isRemovedAll = isRemoved ? isRemovedAll : false;
            }
            return(isRemovedAll);
        }
Beispiel #5
0
 public bool Remove(ProductRemoveCommand cmd)
 {
     return(_repositoryProduct.Remove(cmd.Id));
 }
        public async Task <CommandResponse> Remove(Guid id)
        {
            var removecommand = new ProductRemoveCommand(id);

            return(await _mediatorHandler.SendCommand <ProductRemoveCommand>(removecommand));
        }