Ejemplo n.º 1
0
        protected override async Task Handle(UnsubscribeUserRequest request, CancellationToken cancellationToken)
        {
            var chat = await _subscribedChatRepository.GetById(request.UserId);

            if (chat is null)
            {
                await _botMessageService.SendText("No te encuentras suscripto",
                                                  request.UserId,
                                                  request.ReplyToMessageId);
            }
            else
            {
                SubscribedChat subscribedChat = await _subscribedChatRepository.OpenSubscribedChat();

                subscribedChat.ChatId = request.UserId;

                await _subscribedChatRepository.Delete(subscribedChat);

                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("Es una pena que te vayas 😭");
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("Pero recuerda que puedes volver a suscribirte cuando quieras para seguir recibiendo las últimas noticias de la comunidad. Hasta pronto!");

                await _botMessageService.SendText(stringBuilder.ToString(),
                                                  request.UserId,
                                                  request.ReplyToMessageId);
            }
        }
Ejemplo n.º 2
0
        protected override async Task Handle(UnsubscribeChatRequest request, CancellationToken cancellationToken)
        {
            var chat = await _subscribedChatRepository.GetById(request.ChatId);

            if (chat != null)
            {
                SubscribedChat subscribedChat = await _subscribedChatRepository.OpenSubscribedChat();

                subscribedChat.ChatId = request.ChatId;

                await _subscribedChatRepository.Delete(subscribedChat);
            }
        }