Ejemplo n.º 1
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";
            }
        }