Ejemplo n.º 1
0
        public async Task <ICommandResult> Handle(CharacteristicKeyDeleteCommand command)
        {
            //FFV
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(
                           false,
                           HttpStatusCode.BadRequest,
                           command.Notifications));
            }

            var _verify = await _characteristicKeyRepository.FindByIdTabela(command.Id);

            if (_verify == null)
            {
                return(new GenericCommandResult(false, HttpStatusCode.NotFound, "Não localizado na base"));
            }

            var _entity = new CharacteristicKey
            {
                Id = command.Id
            };

            var _result = await _cudRepository.Delete(_entity);

            //retorna o resultado
            if (!_result)
            {
                return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result));
            }

            return(new GenericCommandResult(true, HttpStatusCode.OK, _result));
        }
Ejemplo n.º 2
0
        public async Task <ICommandResult> Handle(CharacteristicKeyInsertCommand command)
        {
            //FFV
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(
                           false,
                           HttpStatusCode.BadRequest,
                           command.Notifications));
            }

            var _entity = new CharacteristicKey
            {
                CharacteristicId = command.CharacteristicId,
                Description      = command.Description
            };

            var _result = await _cudRepository.Add(_entity);

            //retorna o resultado
            if (!_result)
            {
                return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result));
            }

            return(new GenericCommandResult(true, HttpStatusCode.Created, _result));
        }