Beispiel #1
0
        public Operation RequestUserActivation(string targetUser)
        => _authorizer.AuthorizeAccess(UserContext.CurrentProcessPermissionProfile(), () =>
        {
            var user = _query.GetUserById(targetUser);
            if (user.Status != (int)AccountStatus.InActive)
            {
                throw new Exception("invalid account state");
            }

            var verification = _query.GetLatestContextVerification(user, Constants.VerificationContext_UserActivation);


            //if no unverified context still exists in the db, create a new one
            if (verification == null || verification.Verified || verification.ExpiresOn <= DateTime.Now)
            {
                var expiry = _settingsManager.GetSetting(Constants.Settings_DefaultContextVerificationExpirationTime)
                             .Resolve()
                             .ParseData <TimeSpan>();
                verification = new ContextVerification
                {
                    Context           = Constants.VerificationContext_UserActivation,
                    Target            = user,
                    ExpiresOn         = DateTime.Now + expiry,
                    VerificationToken = RandomAlphaNumericGenerator.RandomAlphaNumeric(50)
                };

                _pcommand.Add(verification).Resolve();
            }

            return(_backgroundProcessor.EnqueueOperation <IEmailPush>(_mp => _mp.SendMail(new AccountActivation
            {
                From = Constants.MailOrigin_DoNotReply,
                Subject = "Account - Email Verification",
                Target = user.UserId,
                Link = _apiProvider.GenerateUserActivationVerificationUrl(verification.VerificationToken, targetUser).Result
            }))
                   .Then(opr => { }));
        });
Beispiel #2
0
        private User NextUpgradeBeneficiary(User lastBeneficiary, int nextLvel, int nextCycle)
        => _query.Uplines(lastBeneficiary)
        .FirstOrDefault(_rn =>
        {
            var bl = _query.CurrentBitLevel(_rn.User);
            if (bl == null)
            {
                return(false);
            }
            else if (bl.Cycle < nextCycle || bl.Cycle == nextCycle && bl.Level <= nextLvel)
            {
                bl.SkipCount++;
                _pcommand.Update(bl);

                var message = @"
<strong>Ouch!</strong> You just missed a donation...
<p>
    <span class='text-muted'>Your level</span><br />
    {0}
</p>
<p>
    <span class='text-muted'>Downline</span><br />
    {1}
</p>
<p>
    <span class='text-muted'>Downline Level</span><br />
    {2}
</p>
".ResolveParameters(new BitCycle {
                    Level = nextLvel, Cycle = nextCycle
                }, _rn.UserId, new BitCycle {
                    Level = bl.Level, Cycle = bl.Cycle
                });

                //notify user
                _notifier.NotifyUser(new Notification
                {
                    Type     = NotificationType.Info,
                    TargetId = bl.UserId,
                    Title    = "Missed donation",
                    Message  = message
                })
                .Resolve();

                //send email
                _backgroundProcessor.EnqueueOperation <IEmailPush>(_mp => _mp.SendMail(new GenericMessage
                {
                    From        = Constants.MailOrigin_DoNotReply,
                    Recipients  = new[] { bl.UserId },
                    Subject     = "Missed donation",
                    LogoUrl     = _urlProvider.LogoUri().Resolve(),
                    LogoTextUrl = _urlProvider.LogoTextUri().Resolve(),
                    Message     = message
                }))
                .Resolve();

                return(false);
            }
            else
            {
                return(true);
            }
        })?.User
        ?? lastBeneficiary;