Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            if (!Authentication.IsActive())
            {
                Response.Redirect("~/Login.aspx");
                return;
            }

            User user = Database.GetUser(Authentication.GetEmail());

            if (user == null)
            {
                Authentication.LogOut();
                return;
            }

            UserCredits.InnerText = user.Credit.ToString() + " ";

            if (GroupedDropDownList.Items.Count == 0)
            {
                foreach (Category category in Category.GetCategories())
                {
                    GroupedDropDownList.AddItemGroup(category.Name);

                    foreach (Subcategory subcategory in category.Subcategories)
                    {
                        GroupedDropDownList.Items.Add(new ListItem(subcategory.Name, category.Id.ToString() + "-" + subcategory.Id.ToString()));
                    }
                }
            }

            if (DurationDropDownList.Items.Count == 0)
            {
                DurationDropDownList.Items.Add(new ListItem("30 Days", "30"));
                DurationDropDownList.Items.Add(new ListItem("14 Days", "14"));
                DurationDropDownList.Items.Add(new ListItem("7 Days", "7"));
                DurationDropDownList.Items.Add(new ListItem("3 Days", "3"));
                DurationDropDownList.Items.Add(new ListItem("1 Day", "1"));
            }

            for (int i = 0; i < Constants.ImagesPerListing; i++)
            {
                FileUpload fileUpload = new FileUpload();
                fileUpload.Attributes["style"] = "display: none";

                FileUploads.Controls.Add(fileUpload);
            }
        }
Exemplo n.º 2
0
        private void SetListing(Advertisement ad)
        {
            if (GroupedDropDownList.Items.Count == 0)
            {
                foreach (Category category in Category.GetCategories())
                {
                    GroupedDropDownList.AddItemGroup(category.Name);
                    foreach (Subcategory subcategory in category.Subcategories)
                    {
                        GroupedDropDownList.Items.Add(new ListItem(subcategory.Name, category.Id + "-" + subcategory.Id.ToString()));
                    }
                }
            }

            TitleTextBox.Text = ad.Title;
            GroupedDropDownList.SelectedValue = ad.Category + "-" + ad.Subcategory;
            DescriptionTextBox.Text           = ad.Description;

            if (ad.IsExpired())
            {
                TitleTextBox.Enabled        = false;
                GroupedDropDownList.Enabled = false;
                DescriptionTextBox.Enabled  = false;
                EditButtons.Visible         = false;

                ExpirationText.InnerText = "This listing expired on " + ad.GetExpirationDate() + ".";

                if (ad.Anonymous)
                {
                    VisiblityText.InnerHtml = "This listing was anonymous.";
                }
                else
                {
                    VisiblityText.InnerHtml = "This listing was not anonymous.";
                }

                if (ad.Boosted)
                {
                    BoostText.InnerHtml = "This listing was boosted.";
                }
                else
                {
                    BoostText.InnerHtml = "This listing was not boosted.";
                }
            }
            else
            {
                ExpirationText.InnerText = "This listing expires on " + ad.GetExpirationDate() + ".";

                if (ad.Anonymous)
                {
                    VisiblityText.InnerHtml = "This listing is anonymous.";
                }
                else
                {
                    VisiblityText.InnerHtml = "This listing is not anonymous.";
                }

                if (ad.Boosted)
                {
                    BoostText.InnerHtml = "This listing is boosted.";
                }
                else
                {
                    BoostText.InnerHtml = "This listing is not boosted.";
                }
            }

            if (ad.Anonymous)
            {
                Visibility.Attributes["class"] = "option-container invisible";
                Spy.Attributes["class"]        = "spy white";
            }
            else
            {
                Visibility.Attributes["class"] = "option-container visible";
                Spy.Attributes["class"]        = "spy black";
            }

            if (ad.Boosted)
            {
                Boost.Attributes["class"] = "option-container enabled";
                Star.Attributes["class"]  = "star enabled-star";
            }
            else
            {
                Boost.Attributes["class"] = "option-container disabled";
                Star.Attributes["class"]  = "star disabled-star";
            }
        }