/// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event to initialize the sponsor.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            //TODO create sponsor right
            WebUtils.CheckRightsForAdminPagesPages(false);
            MaintainScrollPositionOnPostBack = true;

            SponsorID = Request.QueryString["id"];
            Delete = Request.QueryString["delete"];
            if (!String.IsNullOrEmpty(SponsorID))
                IsEdit = Guid.TryParse(SponsorID, out GuidID);
            if (!String.IsNullOrEmpty(Delete))
                IsDelete = Guid.TryParse(Delete, out GuidID);

            if (!IsPostBack)
            {
                imgLogo.CropConstraint = new FixedCropConstraint(GfxUnit.Pixel,300, 194.117F);
                imgLogo.PreviewFilter = new FixedResizeConstraint(GfxUnit.Pixel, 300, 194.117F, Color.Black);
            }

            if (IsEdit)
            {
                PageTitle.Text = labels.editSponsor;
                crSponsor = new CRSponsor(GuidID, false);
                txtName.Text = crSponsor.Name;
                txtUrl.Text = crSponsor.Url;

                BindSponsorTypes(crSponsor.SponsorType);
                //ddlSponsorType.SelectedValue = ((int) crSponsor.SponsorType).ToString();

                if (!string.IsNullOrEmpty(crSponsor.LogoURL))
                    imgLogo.LoadImageFromFileSystem(crSponsor.LogoPhysicalPath);
                cbActive.Checked = crSponsor.Active;

                cbShowInWidget.Checked = crSponsor.WidgetSwitch;
                cbShowInPlayerSwitch.Checked = crSponsor.PlayerSwitch;
                cbShowInPlayerSolid.Checked = crSponsor.PlayerSolid;
                cbShowInMobileSwitch.Checked = crSponsor.MobileSwitch;
                cbShowInMobileSolid.Checked = crSponsor.MobileSolid;

                ddlMobileFrequency.SelectedValue = ((int)crSponsor.MFrequency).ToString();

                txtDescription.Text = crSponsor.Description;
                dtEndDate.SetDate(crSponsor.EndDate);

            }
            else if(IsDelete)
            {
                crSponsor = new CRSponsor(GuidID, true);
                Response.Write(crSponsor.Delete().ToString());
                Response.Redirect("Sponsoren.aspx");
            }
            else
            {
                PageTitle.Text = labels.addNewSponsor;
                crSponsor = new CRSponsor();
                BindSponsorTypes(SponsorType.VriendenVanCr);
            }

            if(IsEdit)
            {
            }
            else if (!String.IsNullOrEmpty(Request.QueryString["delete"]) &&
                     Request.QueryString["delete"].Length == 36)
            {
                var id = new Guid(Request.QueryString["delete"]);
            }
            else
            {
                //TODO create sponsor right
                if (!Security.IsAuthorizedTo(Rights.CreateNewPages))
                {
                    Response.Redirect(Utils.RelativeWebRoot);
                    return;
                }

               //TODO create sponsor right
                //cbActive.Checked = Security.IsAuthorizedTo(Rights.PublishOwnPages);
            }
            Page.Title = labels.sponsoren;

            base.OnInit(e);
        }
예제 #2
0
    /// <summary>
    /// Updates the JSON files for sponsor. It is smart enough to decide if it should or shouldn't update. Pass null or use the parameterless method for extended smartness.
    /// </summary>
    /// <param name="sponsor">CRSponsor item to base the decision on whether it should or shouldn't update.</param>
    private static void updateJSON(CRSponsor sponsor)
    {
        bool shouldUpdateMobileSwitch = sponsor == null || sponsor.MobileSwitch;
        bool shouldUpdatePlayerSwitch = sponsor == null || sponsor.PlayerSwitch;
        bool shouldUpdateWidgetSwitch = sponsor == null || sponsor.WidgetSwitch;
        bool shouldUpdateMobileSolid = sponsor == null || sponsor.MobileSolid;
        bool shouldUpdatePlayerSolid = sponsor == null || sponsor.PlayerSolid;

        if (shouldUpdateMobileSwitch || shouldUpdatePlayerSwitch || shouldUpdateWidgetSwitch || shouldUpdateMobileSolid || shouldUpdatePlayerSolid)
        {
            var sponsors = GetList().Where(s => s.Active);
            if (shouldUpdateMobileSwitch) updateMobileSwitchJSON(sponsors);
            //if (shouldUpdatePlayerSwitch) updatePlayerSwitchJSON();
            //if (shouldUpdateWidgetSwitch) updateWidgetSwitchJSON();
        }
    }