Example #1
0
        public async Task <MethodResult> ExecuteAsync(CriarUsuarioCommand command)
        {
            if (command == null)
            {
                return(Error(Messages.ComandoInvalido));
            }

            var usuario = new UsuarioMapper().MapFrom(command);

            var result = await _service.InserirAsync(usuario);

            if (result.Failed)
            {
                return(result);
            }

            var output = new UsuarioMapper().OutputFrom(usuario);

            return(Success(output));
        }
Example #2
0
        public async Task <CommandReturn> ExecuteAsync(NewUserCommand command)
        {
            if (command == null)
            {
                return(Error(Messages.InvalidCommand));
            }

            var user = new UserMapper().MapFrom(command);

            var result = await _service.InserirAsync(user);

            if (result.Failed)
            {
                return(result);
            }

            var output = new UserMapper().OutputFrom(user);

            return(Success(output));
        }