Пример #1
0
        public static void Buy(Member user, PTCOfferWallPack pack, PurchaseBalances targetBalance, List <UserUrl> userUrls,
                               string title, string description, GeolocationUnit geoUnit, bool pcAllowed, bool mobileAllowed,
                               bool autosurfEnabled, int maxSingleUserDailyViews)
        {
            if (pack.Adverts != userUrls.Count)
            {
                throw new MsgException(string.Format(U6002.NUMBEROFURLSERROR, pack.Adverts));
            }

            if (userUrls.Any(u => u.Status != AdvertStatus.Active))
            {
                throw new MsgException("Fraud! Only active urls are permitted.");
            }

            PurchaseOption.ChargeBalance(user, pack.Price, PurchaseOption.Features.PtcOfferWall.ToString(), targetBalance, "PTC OfferWall");

            var offerWall = new PTCOfferWall(user.Id, pack, title, description, pcAllowed, mobileAllowed, autosurfEnabled, maxSingleUserDailyViews);

            if (geoUnit != null)
            {
                offerWall.AddGeolocation(geoUnit);
            }

            offerWall.Save();
            offerWall.MapWithUrls(userUrls);

            MatrixBase.TryAddMemberAndCredit(user, pack.Price, AdvertType.PTCOfferWall);
        }
Пример #2
0
        public void Credit()
        {
            var offerWall = new PTCOfferWall(ptcOfferWallId);

            offerWall.Watched();

            var crediter          = new PtcOfferWallCrediter(offerWall.PricePaid / offerWall.CompletionTimesBought, publishersWebsite.UserId);
            var moneyLeftForPools = crediter.Credit(HandleSuccessfulCredit);
        }
Пример #3
0
        public List <PTCOfferWall> GetOfferWalls()
        {
            var ptcOfferWallViews = PTCOfferWallView.GetWatchedToday(externalUsername, PublishersWebsite.Id);

            var activeOffers   = PTCOfferWall.GetActive(countryCode, this.age, Gender, isMobile);
            var offersToReturn = new List <PTCOfferWall>();

            foreach (var o in activeOffers)
            {
                if (ptcOfferWallViews.Count(v => v.PTCOfferWallId == o.Id) < o.SingleUserViewsPerDay)
                {
                    offersToReturn.Add(o);
                }
            }

            offersToReturn.Shuffle(new Random());

            return(offersToReturn);
        }