コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Page.Title   = "Setup Ballot Page Banner Ad";
                H1.InnerHtml = "Setup Ballot Page Banner Ad";
                _SetupAdDialogInfo.LoadControls();
                FeedbackSetupAd.AddInfo("Ad information loaded.");
                SetupSampleAd();
            }

            var body = Master.FindControl("body") as HtmlGenericControl;

            Debug.Assert(body != null, "body != null");
            body.Attributes.Add("data-state", StateCode);

            AdRate.InnerText =
                DB.Vote.Master.GetBallotAdRate(0)
                .ToString("C", CultureInfo.CreateSpecificCulture("en-US"));
            State.InnerText = StateCache.GetStateName(StateCode.SafeString());

            if (AdminPageLevel == AdminPageLevel.Unknown)
            {
                UpdateControls.Visible = false;
                NoJurisdiction.CreateStateLinks("/admin/SetupBallotPageBannerAd.aspx?state={StateCode}");
                NoJurisdiction.Visible = true;
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Page.Title   = "Setup Compare Page Banner Ad";
                H1.InnerHtml = "Setup Compare Page Banner Ad";
                _SetupAdDialogInfo.LoadControls();
                FeedbackSetupAd.AddInfo("Ad information loaded.");
                SetupSampleAd();
            }

            var election    = Elections.GetElectionDesc(QueryElection);
            var officeTable = Offices.GetCacheData(QueryOffice);
            var office      = officeTable.Count > 0 ? Offices.GetLocalizedOfficeName(officeTable[0]) : null;

            if (IsNullOrWhiteSpace(election) || IsNullOrWhiteSpace(office))
            {
                Response.StatusCode = 404;
                return;
            }

            Election.InnerText = election;
            Office.InnerText   = office;
            AdRate.InnerText   =
                DB.Vote.Master.GetContestAdRate(0)
                .ToString("C", CultureInfo.CreateSpecificCulture("en-US"));
        }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Page.Title   = "Setup Home Page Banner Ad";
         H1.InnerHtml = "Setup Home Page Banner Ad";
         _SetupAdDialogInfo.LoadControls();
         FeedbackSetupAd.AddInfo("Ad information loaded.");
         SetupSampleAd();
     }
     AdRate.InnerText =
         DB.Vote.Master.GetHomeAdRate(0)
         .ToString("C", CultureInfo.CreateSpecificCulture("en-US"));
 }
コード例 #4
0
        protected void ButtonSetupAd_OnClick(object sender, EventArgs e)
        {
            var politicianKey = AdSetupCandidate.Value;
            var electionKey   = SafeGetElectionKey();
            var officeKey     = SafeGetOfficeKey();

            CandidateAdName.InnerText = PageCache.GetTemporary().Politicians
                                        .GetPoliticianName(politicianKey);
            CandidateAdOffice.InnerText   = Offices.FormatOfficeName(officeKey);
            CandidateAdElection.InnerText = PageCache.GetTemporary().Elections
                                            .GetElectionDesc(electionKey);
            CandidateAdRate.InnerText =
                Offices.GetAdRate(electionKey, officeKey)
                .ToString("C", CultureInfo.CreateSpecificCulture("en-US"));

            switch (SetupAdReloading.Value)
            {
            case "reloading":
            {
                SetupAdReloading.Value = Empty;
                _SetupAdDialogInfo.LoadControls();
                FeedbackSetupAd.AddInfo("Ad information loaded.");
                var urlItem  = _SetupAdDialogInfo.First(i => i.Column == "AdUrl");
                var videoUrl = urlItem.DataControl.GetValue();
                if (IsNullOrWhiteSpace(videoUrl))
                {
                    videoUrl = DefaultAdVideo.Value = PageCache.GetTemporary().Politicians
                                                      .GetYouTubeWebAddress(politicianKey);
                }
                else
                {
                    DefaultAdVideo.Value = Empty;
                }
                SetupSampleAd(electionKey, officeKey, politicianKey, videoUrl);
            }
            break;

            case "":
            {
                // normal update
                _SetupAdDialogInfo.ClearValidationErrors();
                DefaultAdVideo.Value = Empty;

                // handle default date
                var dateItem = _SetupAdDialogInfo.First(i => i.Column == "AdTimeStamp");
                if (IsNullOrWhiteSpace(dateItem.DataControl.GetValue()))
                {
                    dateItem.DataControl.SetValue(DateTime.UtcNow.ToShortDateString());
                }

                var adTypeItem = _SetupAdDialogInfo.First(i => i.Column == "AdType");
                var urlItem    = _SetupAdDialogInfo.First(i => i.Column == "AdUrl");
                var thumbItem  = _SetupAdDialogInfo.First(i => i.Column == "AdThumbnailUrl");
                switch (adTypeItem.DataControl.GetValue())
                {
                case "Y": // YouTube
                    // make sure we have a thumbnail video if main URL is not a video
                    var videoUrl = urlItem.DataControl.GetValue();
                    if (!videoUrl.IsValidYouTubeVideoUrl())
                    {
                        var thumbUrl = thumbItem.DataControl.GetValue();
                        if (IsNullOrWhiteSpace(thumbUrl))
                        {
                            FeedbackSetupAd.PostValidationError(thumbItem.DataControl,
                                                                "Thumbnail URL is required for channels or playlists");
                        }
                    }
                    // clear the image name
                    var adImageNameItem =
                        _SetupAdDialogInfo.First(i => i.Column == "AdImageName");
                    adImageNameItem.DataControl.SetValue(Empty);
                    break;

                case "I": // image
                    // clear the video and thumbnail
                    urlItem.DataControl.SetValue(Empty);
                    thumbItem.DataControl.SetValue(Empty);
                    break;
                }

                _SetupAdDialogInfo.Update(FeedbackSetupAd);

                ControlSetupAdAdImageUpdated.Text = "False";

                if (FeedbackSetupAd.ValidationErrorCount == 0)
                {
                    SetupSampleAd(electionKey, officeKey, politicianKey);
                }
            }
            break;

            default:
                throw new VoteException(
                          $"Unknown reloading option: '{EditPoliticianReloading.Value}'");
            }
        }