예제 #1
0
        public async Task RewardReferralAsync(ApplicationUser userWhoReceivedReferral, string referralCode)
        {
            Debug.Assert(userWhoReceivedReferral != null);
            Debug.Assert(!String.IsNullOrEmpty(referralCode));

            var referral = await db.Referrals.FindAsync(referralCode);

            var userWhoSentReferral = referral.ApplicationUser;

            // reward the users somehow
            // points
            // title
            // achievement

            userWhoReceivedReferral.IncreasePoints(100);

            // only reward the referral user if they are still active
            if (userWhoSentReferral.IsActive)
            {
                userWhoSentReferral.IncreasePoints(100);
            }

            referral.IsRedeemed = true;

            await db.SaveChangesAsync();

            await MilestoneService.AwardAchievedMilestonesAsync(userWhoSentReferral.Id, (int)MilestoneTypeValues.ReferralSignUps);
        }
예제 #2
0
        internal static MilestoneService Create(IdentityFactoryOptions <MilestoneService> options, IOwinContext context)
        {
            var service = new MilestoneService(context.Get <ApplicationDbContext>(), new EmailService());

            return(service);
        }