Beispiel #1
0
        public RegistrationTransactionModel(Message message, string username, string firstname)
            : base(message)
        {
            UserFirstName = firstname;

            TransactionType = Enums.TransactionType.Registration;

            User = new UserModel
            {
                TelegramId = RecipientId,
                Username   = username,
                IsFree     = true
            };

            TransactionState = new RegistrationInitiated();
        }
Beispiel #2
0
        public async Task Execute(object transaction, ITelegramBotClient botClient, ILogger logger, IDbContext db)
        {
            var currentTransaction = transaction as CommandTransactionModel;

            logger.LogDebug("Start command was initiated by {username}({userid})",
                            currentTransaction.Message.From.Username,
                            currentTransaction.Message.From.Id);

            if (TransactionsContainer.DateForUserExists(currentTransaction.Message.From.Id))
            {
                await botClient.SendTextMessageAsync(currentTransaction.Message.From.Id, Messages.YouHaveAnActiveDate);

                return;
            }

            var registrationTransaction = new Models.RegistrationTransactionModel(currentTransaction.Message,
                                                                                  currentTransaction.Message.From.Username,
                                                                                  currentTransaction.Message.From.FirstName);

            RegistrationInitiated?.Invoke(registrationTransaction);
            return;
        }