Пример #1
0
    protected void ExpiredFavoriteGridView_DataSource_Init(object sender, EventArgs e)
    {
        string favoriteIds = FavoriteAd.GetUserFavoritesCommaDelimited(Member.CurrentId, FavoriteAdType.PTC);

        ExpiredFavoriteGridView_DataSource.SelectCommand = string.Format("SELECT PtcAdvertId, Title, Description, TargetURL FROM PtcAdverts " +
                                                                         "WHERE Status != " + (int)AdvertStatus.Active + " AND PtcAdvertId IN ({0})", favoriteIds);
    }
Пример #2
0
    public static void AddToFavorites(int userId, int adId, FavoriteAdType type)
    {
        FavoriteAd ad = new FavoriteAd();

        ad.UserId   = userId;
        ad.AdvertId = adId;
        ad.Type     = type;
        ad.Save();
    }
Пример #3
0
 protected void FavoriteAdsImageButton_Click(object sender, EventArgs e)
 {
     if (Member.IsLogged)
     {
         if (FavoriteAd.IsFavorite(Member.CurrentId, Object.Id, FavoriteAdType.PTC))
         {
             FavoriteAd.RemoveFromFavorites(Member.CurrentId, Object.Id, FavoriteAdType.PTC);
             favoriteImg.Visible  = false;
             favoriteImg2.Visible = false;
         }
         else
         {
             FavoriteAd.AddToFavorites(Member.CurrentId, Object.Id, FavoriteAdType.PTC);
             favoriteImg.Visible  = true;
             favoriteImg2.Visible = true;
         }
     }
 }
Пример #4
0
    protected void LoadAds()
    {
        Form.Action = Request.RawUrl;

        List <PtcAdvert> AvailableAdList;

        CreatedCustomCategories = new List <int>();

        Member user = null;

        if (Member.IsLogged)
        {
            user = Member.Current;
            int temporaryAdvertId = 0;
            if (AppSettings.PtcAdverts.BlockPtcAdvertsAfterMissingPointer &&
                Request.Params.Get("__EVENTARGUMENT5") != null && Int32.TryParse(Request.Params.Get("__EVENTARGUMENT5"), out temporaryAdvertId))
            {
                // User missed the anti-robot button 3 times
                // Blocking this particualr ad for him
                List <int> av = user.AdsViewed;
                av.Add(temporaryAdvertId); // Blocking = adding to watched
                user.AdsViewed = av;
                user.Save();

                NotificationManager.RefreshWithMember(NotificationType.NewAds, user);
            }

            AvailableAdList = PtcAdvert.GetActiveAdsForUser(user);
        }
        else
        {
            AvailableAdList = PtcAdvert.GetAllActiveAds();
        }

        if (AvailableAdList.Count == 0)
        {
            MenuMultiView.Visible     = false;
            NoPTCpanelWrapper.Visible = true;
            NoPTCpanel.Visible        = true;
            NoPTCpanel.Text           = U6003.NOPTC;
        }
        else
        {
            if (!string.IsNullOrWhiteSpace(Request.Params.Get("__EVENTARGUMENT")))
            {
                string agrument = Request.Params.Get("__EVENTARGUMENT");
                if (PTCSercurityManager.IsPTCAdvertFound(agrument, AvailableAdList))
                {
                    PTCSercurityManager.Release();
                }
            }

            //Sort by favorite?
            if (Member.IsLogged)
            {
                if (SortBy1.SelectedValue == "Favorite")
                {
                    var favorites = FavoriteAd.GetUserFavorites(Member.CurrentId, FavoriteAdType.PTC);
                    AvailableAdList = AvailableAdList.OrderByDescending(i => favorites.Contains(i.Id)).ToList();
                }
                else if (SortBy1.SelectedValue == "Voted")
                {
                    var favorites = FavoriteAd.GetUserFavorites(Member.CurrentId, FavoriteAdType.PTC);
                    AvailableAdList = AvailableAdList.OrderByDescending(i => i.CaptchaYesAnswers - i.CaptchaNoAnswers).ToList();
                }
            }

            //Display proper ads to the Member
            try
            {
                //Lets get the proper ads to the member
                foreach (PtcAdvert Ad in AvailableAdList)
                {
                    bool IsSearch = !string.IsNullOrWhiteSpace(SearchTextBox.Text);

                    if (!IsSearch || (IsSearch && IsSearchRequirementsMeet(Ad, SearchTextBox.Text)))
                    {
                        if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom)
                        {
                            //Display Custom Categories
                            CustomCategoriesPlaceHolder.Visible = true;
                            if (!CreatedCustomCategories.Contains(Ad.CategoryId))
                            {
                                CreatedCustomCategories.Add(Ad.CategoryId);
                            }

                            CustomCategoriesPlaceHolder.Controls.Add(GetAdHTML(Ad, user));
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(Ad.Description) && Ad.IsStarredAd == false)
                            {
                                SmallAdsLiteral.Controls.Add(GetAdHTML(Ad, user, ""));
                            }
                            else
                            {
                                AdsLiteral.Controls.Add(GetAdHTML(Ad, user, ""));
                            }
                        }
                    }
                }
                if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom)
                {
                    foreach (var categoryId in CreatedCustomCategories)
                    {
                        LoadCustomCategoryButton(categoryId);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw ex;
            }
        }
    }
Пример #5
0
    public override void DataBind()
    {
        base.DataBind();

        if (Member.IsLogged)
        {
            Member user = Member.CurrentInCache;

            UserEarnedMoney   = PtcAdvert.CalculateNormalMemberEarnings(user, Object);
            EarningsDR        = PtcAdvert.CalculateEarningsFromDirectReferral(user, Object);
            EarningsRR        = PtcAdvert.CalculateEarningsFromRentedReferral(user, Object);
            EarningsPoints    = user.Membership.AdvertPointsEarnings;
            EarningsAdCredits = user.Membership.PTCCreditsPerView;
        }
        else
        {
            //Public ad view
            UserEarnedMoney   = PtcAdvert.CalculateNormalMemberEarnings(Membership.Standard, Object);
            EarningsDR        = PtcAdvert.CalculateEarningsFromDirectReferral(Membership.Standard, Object);
            EarningsRR        = PtcAdvert.CalculateEarningsFromRentedReferral(Membership.Standard, Object);
            EarningsPoints    = Membership.Standard.AdvertPointsEarnings;
            EarningsAdCredits = Membership.Standard.PTCCreditsPerView;
        }

        //Display PTC Advert Type
        if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.PTC)
        {
            //Starred Ads
            if (Object.IsStarredAd)
            {
                starImg.Visible  = true;
                starImg2.Visible = true;
            }
            else
            {
                starImg.Visible  = false;
                starImg2.Visible = false;
            }

            //Favorite Ads
            if (AppSettings.PtcAdverts.FavoriteAdsEnabled && Member.IsLogged &&
                FavoriteAd.IsFavorite(Member.CurrentId, Object.Id, FavoriteAdType.PTC))
            {
                favoriteImg.Visible  = true;
                favoriteImg2.Visible = true;
                FavoriteCssClass     = " fav";
            }
            else
            {
                favoriteImg.Visible  = false;
                favoriteImg2.Visible = false;
            }

            if (IsActive)
            {
                ActiveAdvertPlaceHolder.Visible = true;
            }
            else
            {
                InactiveAdvertPlaceHolder.Visible = true;
            }

            if (ImageUrl != null)
            {
                //    PtcImage.ImageUrl = PtcImage2.ImageUrl = ImageUrl;
                ImageBackgroundStyle = "background: url(" + ResolveUrl(ImageUrl) + ");";
            }


            if (AppSettings.PtcAdverts.PTCImagesEnabled)
            {
                ImageClass = "has-image";
            }
            else
            {
                ImageClass = "";
            }

            CashLinkPlaceHolder.Visible = false;
        }
        //Display Cash Links Advert Type
        else if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.CashLink)
        {
            ActiveAdvertPlaceHolder.Visible   = false;
            InactiveAdvertPlaceHolder.Visible = false;
            if (IsActive)
            {
                CashLinkPlaceHolder.Visible = true;
            }
            else
            {
                CashLinkPlaceHolderInActive.Visible = true;
            }

            if (IsPreview) //Preview fix
            {
                CashLinkDiv.Attributes["class"] = "Abox CashLinkBox";
            }
        }
    }