示例#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
 private PTCOfferWall(int userId, PTCOfferWallPack pack, string title, string description,
                      bool pcAllowed, bool mobileAllowed, bool autosurfEnabled, int maxSingleUserDailyViews)
 {
     UserId                = userId;
     Status                = AdvertStatus.Active;
     CompletionTimes       = 0;
     CompletionTimesBought = pack.CompletionTimes;
     PricePaid             = pack.Price;
     DisplayTime           = pack.DisplayTime;
     Adverts               = pack.Adverts;
     Title                 = title;
     Description           = description;
     PCAllowed             = pcAllowed;
     MobileAllowed         = mobileAllowed;
     AutosurfEnabled       = autosurfEnabled;
     SingleUserViewsPerDay = maxSingleUserDailyViews;
 }
示例#3
0
        public static void Create(int completionTimes, Money price, int adverts, int displayTime)
        {
            var pack = new PTCOfferWallPack(completionTimes, price, adverts, displayTime);

            pack.Save();
        }
示例#4
0
 public static bool ArePacksConfigured()
 {
     return(PTCOfferWallPack.AreAnyActive());
 }