Beispiel #1
0
        public async Task EnsureRegistrationEnded(string uid)
        {
            var user = await _dbContext.IncompleteUsers.FindAsync(uid);

            if (user != null)
            {
                _dbContext.IncompleteUsers.Remove(user);
                await _dbContext.SaveChangesAsync(CancellationToken.None);
            }
        }
Beispiel #2
0
        protected override async Task Base(Messaging message)
        {
            var uid  = message.Sender.Id;
            var user = await _dbContext.IncompleteUsers.FindAsync(uid);

            _dbContext.IncompleteUsers.Remove(user);
            await _dbContext.SaveChangesAsync(CancellationToken.None);

            await _apiClient.Send(new SendRequest(uid,
                                                  new Message(await _translator.TranslateString("subscription-cancelled", user.PreferredLanguage))));
        }
Beispiel #3
0
        protected override async Task EndRegistration(IncompleteUser user)
        {
            await _mediator.Send(user.ToCreateSubscriptionCommand());

            _dbContext.IncompleteUsers.Remove(user);
            await _dbContext.SaveChangesAsync(CancellationToken.None);

            await _apiClient.Send(new SendRequest(user.Id, new Message(
                                                      await _translator.TranslateString("congratulations", user.PreferredLanguage), new[]
            {
                new QuickReply(await _translator.TranslateString("cancel-button", user.PreferredLanguage),
                               new Payload(PayloadType.Cancel).ToJson())
            })));
        }
        protected override async Task Base(Messaging message)
        {
            var incompleteUser = new IncompleteUser(message.Sender.Id, _configuration["CultureSettings:DefaultCulture"]);

            await _dbContext.IncompleteUsers.AddAsync(incompleteUser);

            await _dbContext.SaveChangesAsync(CancellationToken.None);

            await _langHandler.ShowInstruction(incompleteUser);

            _backgroundJobClient.Schedule <EnsureRegistrationEndedJob>(
                x => x.EnsureRegistrationEnded(incompleteUser.Id),
                TimeSpan.FromMinutes(15)
                );
        }