Beispiel #1
0
        public async Task <bool> Handle(AtributosDeleteCommand request, CancellationToken cancellationToken)
        {
            bool           remove        = false;
            AtributoEntity atributoExist = this._atributosRepository.GetElement(_specification.GetAtributoById(request.AtributoId));

            if (atributoExist != null)
            {
                _atributosRepository.RemoveAsync(atributoExist);
                remove = true;
            }

            await this._unitOfWork.CommitAsync(cancellationToken);

            return(remove);
        }
        public async Task <IActionResult> DeleteAtributo(int atributoID)
        {
            //var atr = await _mediator.Send(new AtributosDeleteCommand(atributoID));
            Atributo atributoExistente = _repo.GetElement(_specification.GetAtributoById(atributoID));

            if (atributoExistente != null && atributoExistente.atributoId == atributoID)
            {
                AtributoDto atributoExistenteDto = _mapper.Map <AtributoDto>(atributoExistente);
                await _repo.RemoveAsync(atributoExistente);

                return(Ok(atributoExistenteDto));
            }
            else
            {
                return(NotFound());
            }
        }