コード例 #1
0
        public string GetAsync(string clientID)
        {
            try
            {
                using (_DbContext)
                {
                    ApplicationUser appUser = _DbContext.Users.Where(u => u.Id == clientID).FirstOrDefault();
                    if (appUser == null)
                    {
                        return("ERROR, Unknown user found within Oso script.");
                    }

                    if (!_SubscriptionService.SubscriptionWithinTrafficLimit(appUser, _DbContext) || appUser.AccountSuspended)
                    {
                        return("ERROR, issue found with OsOEasyPromo account, please check account status at OsoEasyPromo.com!");
                    }

                    //Coupon Promotion
                    Promotion couponPromotion = _DbContext.Promotion
                                                .Where(c => c.ApplicationUser.Id == clientID && c.ActivePromotion == true).FirstOrDefault();
                    if (couponPromotion != null && !_PromoService.ActivePromoExpired(couponPromotion.EndDate))
                    {
                        //Task the update to stats out?
                        //https://stackoverflow.com/questions/1018610/simplest-way-to-do-a-fire-and-forget-method-in-c
                        _PromoService.UpdatePromotionStats(couponPromotion, _DbContext);
                        return(_MainJS.GetMainCouponJS(clientID, couponPromotion));
                    }

                    //Social Sharing Promotion
                    SocialSharing socialPromotion = _DbContext.SocialSharing
                                                    .Where(c => c.ApplicationUser.Id == clientID && c.ActivePromotion == true).FirstOrDefault();
                    if (socialPromotion != null)
                    {
                        return(_MainJS.GetMainSocialHTML(socialPromotion));
                    }
                }

                return("WARNING, no active promotion found");
            }
            catch (Exception ex)
            {
                return("ERROR, unknown exception occurred getting promotion.");
            }
        }