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); }
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; }
public static void Create(int completionTimes, Money price, int adverts, int displayTime) { var pack = new PTCOfferWallPack(completionTimes, price, adverts, displayTime); pack.Save(); }
public static bool ArePacksConfigured() { return(PTCOfferWallPack.AreAnyActive()); }