public async Task <ICommandResult> Handle(CharacteristicInsertCommand command)
        {
            //FFV
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(
                           false,
                           HttpStatusCode.BadRequest,
                           command.Notifications));
            }

            Characteristic _entity = new Characteristic();

            _entity.Description = command.Description;
            _entity.CategoryId  = command.CategoryId;

            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));
        }
        public async Task <ICommandResult> Handle(UserInsertCommand command)
        {
            //FFV
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, HttpStatusCode.BadRequest, command.Notifications));
            }

            User _entity = new User();

            _entity.Login    = command.Login;
            _entity.Password = command.Password;
            _entity.Name     = command.Name;
            _entity.Email    = command.Email;

            _entity.Role = (!string.IsNullOrEmpty(command.Role)) ? command.Role : "Administrator";

            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));
        }
Beispiel #3
0
        public async Task <ICommandResult> Handle(ManufacturerInsertCommand command)
        {
            //FFV
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(
                           false,
                           HttpStatusCode.BadRequest,
                           command.Notifications));
            }

            Manufacturer _entity = new Manufacturer(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));
        }