protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e) { //We want to obey OnSort and OnChart events string[] commands = new string[3] { "start", "stop", "remove" }; if (commands.Contains(e.CommandName)) { int index = e.GetSelectedRowIndex() % DirectRefsGridView.PageSize; GridViewRow row = DirectRefsGridView.Rows[index]; string AdId = (row.Cells[1].Text.Trim()); var Ad = new BannerAdvert(Convert.ToInt32(AdId)); switch (e.CommandName) { case "start": Ad.Status = AdvertStatus.Active; break; case "stop": Ad.Status = AdvertStatus.Paused; break; case "remove": Ad.Status = AdvertStatus.Deleted; break; } Ad.SaveStatus(); ShowSuccPanel(); DirectRefsGridView.DataBind(); Response.Redirect("~/user/advert/banners.aspx"); } }
protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e) { //We want to obey OnSort and OnChart events string[] commands = new string[1] { "remove" }; if (commands.Contains(e.CommandName)) { int index = e.GetSelectedRowIndex() % DirectRefsGridView.PageSize; GridViewRow row = DirectRefsGridView.Rows[index]; string AdId = (row.Cells[1].Text.Trim()); var Ad = new BannerAdvert(Convert.ToInt32(AdId)); if (e.CommandName == "remove") { Ad.Status = AdvertStatus.Deleted; Ad.SaveStatus(); RedirectToStart(); } } }
public static Control GetBanner(BannerAdvertDimensions dimensions, Page page, int position = 1) { allBanners = TryGetFromCache(dimensions, page, position); List <BannerAdvert> allBannersFiltered = new List <BannerAdvert>(); if (AppSettings.BannerAdverts.AdvertisingPolicy == BannerPolicy.SellingPackages) { Member User = null; if (Member.IsLogged) { User = Member.CurrentInCache; } foreach (var elem in allBanners) { if (!elem.IsGeolocated) { allBannersFiltered.Add(elem); } else if (elem.IsGeolocated && Member.IsLogged && elem.BannedCountries.Contains(User.Country)) { allBannersFiltered.Add(elem); } } } else { allBannersFiltered = allBanners; //No geolocation in Banner Bidding } _workingBanner = new HyperLink(); int bannerIndex = random.Next(0, allBannersFiltered.Count); _workingBanner = (HyperLink)GetPanelWithDimensionsAndBorder(dimensions, _workingBanner); if (allBannersFiltered.Count > 0) { BannerAdvert ChoosenBanner = allBannersFiltered[bannerIndex]; var te = new Encryption(); HttpContext.Current.Session["SurfBannerAdvertID"] = ChoosenBanner.Id; if (ChoosenBanner.ShouldBeFinished) { ChoosenBanner.Status = AdvertStatus.Finished; ChoosenBanner.SaveStatus(); } if (AppSettings.BannerAdverts.ImpressionsEnabled) { //Count impression ChoosenBanner.Click(); } //Dynamic banner (HTML code instead of image) if (ChoosenBanner.IsDynamic) { Panel panel = new Panel(); panel = (Panel)GetPanelWithDimensionsAndBorder(dimensions, panel); Literal literal = new Literal(); literal.Text = ChoosenBanner.BannerHTML; panel.Controls.Add(literal); return(panel); } dimensions = ChoosenBanner.Dimensions; var Helper = new BannerDisplayerHelper(dimensions); //Now lets create Image Web Control and return it _workingBanner.Target = "_blank"; _workingBanner.NavigateUrl = AppSettings.Site.Url + "link.aspx?id=" + te.EncryptBannerId(ChoosenBanner.Id); _workingBanner.Controls.Clear(); _workingBanner.Controls.Add(Helper.GetBannerImage(ChoosenBanner)); } return(_workingBanner); }