コード例 #1
0
        public Operation <User> VerifyUserActivation(string targetUser, string contextToken)
        => _authorizer.AuthorizeAccess(UserContext.CurrentProcessPermissionProfile(), () =>
        {
            var user = _query.GetUserById(targetUser);
            if (user == null)
            {
                throw new Exception("invalid user");
            }

            var verification = _query.GetContextVerification(user, Constants.VerificationContext_UserActivation, contextToken);
            if (verification.Verified ||
                verification.Context != Constants.VerificationContext_UserActivation)
            {
                throw new Exception("invalid verification");
            }
            else
            {
                verification.Verified = true;
                return(_pcommand.Update(verification)
                       .Then(opr =>
                {
                    user.Status = AccountStatus.Active.As <int>();
                    return _pcommand.Update(user);
                })
                       .Then(opr => _backgroundProcessor.EnqueueOperation <IEmailPush>(_mp => _mp.SendMail(new UserWelcome
                {
                    From = "*****@*****.**",
                    Subject = "Welcome",
                    Target = user.UserId,
                    Link = _apiProvider.GenerateWelcomeMessageUrl().Result,
                    LogoTextUrl = _apiProvider.LogoTextUri().Result,
                    LogoUrl = _apiProvider.LogoUri().Result
                }))
                             .Then(_opr => opr.Result)));
            }
        });
コード例 #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;