protected void LoginAdsGridView_RowCommand(object sender, GridViewCommandEventArgs e) { int index = e.GetSelectedRowIndex() % LoginAdsGridView.PageSize; GridViewRow row = LoginAdsGridView.Rows[index]; var Ad = new LoginAd(Convert.ToInt32(row.Cells[0].Text.Trim())); if (e.CommandName == "start") { Ad.Status = AdvertStatus.Active; Ad.Save(); LoginAdsGridView.DataBind(); } else if (e.CommandName == "stop") { Ad.Status = AdvertStatus.Paused; Ad.Save(); LoginAdsGridView.DataBind(); } else if (e.CommandName == "remove") { Ad.Status = AdvertStatus.Deleted; Ad.Save(); LoginAdsGridView.DataBind(); } }
protected void CreateAdButton_Click(object sender, EventArgs e) { ErrorMessagePanel.Visible = false; SuccMessagePanel.Visible = false; if (Page.IsValid) { try { User = Member.Current; AppSettings.DemoCheck(); if (URL.Enabled) { throw new MsgException(U4200.CHECKURL); } var Ad = new LoginAd { TargetUrl = URL.Text, }; if (AppSettings.LoginAds.LoginAdsCreditsEnabled && LoginAdsCreditsCheckBox.Checked) { //Login Ads Credits Ad.PricePaid = new Money((int)LoginAdCreditsPrice); } else { Ad.PricePaid = AppSettings.LoginAds.Price; } if (chbGeolocation.Checked && AppSettings.LoginAds.IsGeolocationEnabled) { //Now get it from client-state var countriesSelectedDelimited = Request.Form[GeoCountriesValues.Name].Substring(1); GeolocationUnit unit = GeolocationUnit.ParseFromCountries(countriesSelectedDelimited); //Cities unit.Cities = GeoCities.Text; unit.MinAge = Convert.ToInt32(GeoAgeMin.Text); unit.MaxAge = Convert.ToInt32(GeoAgeMax.Text); unit.Gender = (Gender)Convert.ToInt32(GeoGenderList.SelectedValue); Ad.AddGeolocation(unit); } Ad.CreatorUserId = User.Id; Ad.Status = AdvertStatusExtensions.GetStartingStatus(); var displayDate = AdDisplayDateCalendar.SelectedDate; if (displayDate <= DateTime.Now.Date) { throw new MsgException(U4200.SELECTDIFFERENTDISPLAYDATE); } if (LoginManager.GetNumberOfAdsPurchasedForDay(displayDate) >= AppSettings.LoginAds.AdsPerDay) { throw new MsgException(U4200.SELECTDIFFERENTDISPLAYDATE); } Ad.DisplayDate = displayDate; Ad.PurchaseDate = DateTime.Now; if (AppSettings.LoginAds.LoginAdsCreditsEnabled && LoginAdsCreditsCheckBox.Checked) { Ad.TargetBalance = PurchaseBalances.LoginAdsCredits; PurchaseOption.ChargeBalance(User, Ad.PricePaid, PurchaseBalances.LoginAdsCredits, U5001.LOGINAD); string extraViews = string.Format(@"({0} {1})", User.LoginAdsCredits, U4200.AVAILABLE); AvailableLoginAdsCreditsLiteral.Text = extraViews; History.AddPurchase(User.Name, Ad.PricePaid.AsPoints(), U5001.LOGINAD); } else { Ad.TargetBalance = TargetBalanceRadioButtonList.TargetBalance; PurchaseOption.ChargeBalance(User, Ad.PricePaid, TargetBalanceRadioButtonList.Feature, TargetBalanceRadioButtonList.TargetBalance, U5001.LOGINAD); //Pools PoolDistributionManager.AddProfit(ProfitSource.LoginAds, Ad.PricePaid); //Add history entry 1 History.AddPurchase(User.Name, Ad.PricePaid, U5001.LOGINAD); MatrixBase.TryAddMemberAndCredit(User, Ad.PricePaid, AdvertType.Login); } //Save advert Ad.Save(); SuccMessagePanel.Visible = true; SuccMessage.Text = U4200.ADAWAITSAPPROVAL; URL.Text = "http://"; URL.Enabled = true; CheckURLButton.Visible = true; } catch (MsgException ex) { SuccMessagePanel.Visible = false; ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); throw ex; } } }