private void test()
        {
            MsgCommand command = new("stringa1");
            BaseCommandHandler <MsgCommand> handler = _container.Resolve <BaseCommandHandler <MsgCommand> >();

            handler.Handle(command);
        }
        public static Usuario DefinirUsuario <T>(this BaseCommandHandler command, BaseUsuarioCommand <T> request) where T : BaseUsuarioCommand <T>
        {
            var endereco = new Endereco(request.Logradouro, request.Numero, request.Bairro, request.CEP, request.Cidade, request.Estado, request.Complemento);
            var usuario  = Usuario.UsuarioFactory.CriarUsuario(request.Id, request.Nome, request.Sobrenome, request.Sexo, request.Email, CPF.ObterCPFLimpo(request.CPF),
                                                               request.DataDeNascimento, request.Celular, request.Telefone, endereco, request.PerfilId, Senha.GerarSenha(CPF.ObterCPFLimpo(request.CPF).Digitos));

            return(usuario);
        }
Пример #3
0
        public static async Task <Perfil> BuscarPerfilComPermissoes(this BaseCommandHandler command, System.Guid id, IPerfilRepository repository)
        {
            var perfil = await repository.ObterComPermissoesAsync(id);

            if (perfil != null)
            {
                return(perfil);
            }

            return(null);
        }
Пример #4
0
        private async void OnMessage(object sender, MessageEventArgs e)
        {
            var selectedCommand = _selectedCommands?.FirstOrDefault(x => x.ChatId == e.Message.Chat.Id);

            if (selectedCommand != null)
            {
                BaseCommandHandler commandHandler = selectedCommand.Command switch
                {
                    ECommandType.Images => _imagesCommandHandler,
                    ECommandType.Voice => _voiceCommandHandler,
                    ECommandType.Pdf => _pdfCommandHandler,
                    ECommandType.Docx => _docxCommandHandler
                };

                await commandHandler.Handle(e.Message);

                _selectedCommands.Remove(selectedCommand);
            }
            else if (e.Message.Text != null && TryParseCommand(e.Message.Text, out var command))
            {
                if (command == ECommandType.Start)
                {
                    await _botClient.SendTextMessageAsync(e.Message.Chat.Id, "Welcome! I am waiting for your command..");

                    return;
                }

                _selectedCommands.Add(new UserCommand {
                    ChatId = e.Message.Chat.Id, Command = command
                });

                var response = "Ok. Now send " + command switch
                {
                    ECommandType.Images => "image or multiple images",
                    ECommandType.Voice => "voice message",
                    ECommandType.Pdf => "text or images or voice message",
                    ECommandType.Docx => "text or images or voice message",
                };

                await _botClient.SendTextMessageAsync(e.Message.Chat.Id, response);
            }
            else
            {
                await _botClient.SendTextMessageAsync(e.Message.Chat.Id, "Send a valid command");
            }
        }
Пример #5
0
 public static Permissao DefinirPermissao <T>(this BaseCommandHandler command, BasePermissaoCommand <T> request) where T : BasePermissaoCommand <T>
 {
     return(Permissao.PermissaoFactory.CriarPermissao(request.Id, request.Tipo, request.Valor));
 }
Пример #6
0
        public static Perfil DefinirPerfil <T>(this BaseCommandHandler command, BasePerfilCommand <T> request) where T : BasePerfilCommand <T>
        {
            var perfil = Perfil.PerfilFactory.NovoPerfil(request.Id, request.Nome, request.Descricao);

            return(perfil);
        }
Пример #7
0
 public TableMenuItem(SqlCeToolboxPackage package)
 {
     _package = package;
     _handler = new BaseCommandHandler();
     Text     = "Script table...";
 }