Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.RawUrl.StartsWith("/dollarsaver/index"))
                {
                    //Response.Redirect("~/Default.aspx?station_id=" + StationId);
                    DollarSaverRedirect("~/Default.aspx");
                }


                DateTime currentDate = DateTime.Now;
                currentDate = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day);

                StationTableAdapter stationAdapter = new StationTableAdapter();

                DollarSaverDB.StationRow station = stationAdapter.GetStation(StationId)[0];
                siteType = (SiteType)station.SiteTypeId;

                CertificateTableAdapter certificateAdapter = new CertificateTableAdapter();


                //stationNameLabel.Text = station.Name;
                if (!station.IsContent1Null())
                {
                    content1Label.Text = station.Content1;
                }

                if (!station.IsContent2Null())
                {
                    content2Label.Text = station.Content2;
                }

                String ImageDir = Request.PhysicalApplicationPath + station.ImageDirUrl;
                if (station.StationSiteType == SiteType.Standard)
                {
                    standardHolder.Visible = true;
                    dealHolder.Visible     = false;

                    signUpTopLink.NavigateUrl = GetUrl(signUpTopLink.NavigateUrl);

                    SpecialSettingsTableAdapter            specialSettingsAdapter = new SpecialSettingsTableAdapter();
                    DollarSaverDB.SpecialSettingsDataTable specialSettingsTable   = specialSettingsAdapter.GetSpecialSettings(StationId);

                    bool dailyHeader = false;
                    if (specialSettingsTable.Count == 1)
                    {
                        dailyHeader = specialSettingsTable[0].DailyHeader;
                    }

                    Image dailyWeeklyImage = new Image();

                    if (dailyHeader)
                    {
                        //dailyWeeklyImage.SkinID = "dailyImage";

                        if (!station.Content.IsDailyDealImageNull() && File.Exists(ImageDir + station.Content.DailyDealImage))
                        {
                            dailyWeeklyImage.ImageUrl = station.ImageDirUrl + station.Content.DailyDealImage;
                        }
                        else
                        {
                            dailyWeeklyImage.ImageUrl = "~/images/boxtop_daily.gif";
                        }
                    }
                    else
                    {
                        //dailyWeeklyImage.SkinID = "weeklyImage";
                        if (!station.Content.IsWeeklyDealImageNull() && File.Exists(ImageDir + station.Content.WeeklyDealImage))
                        {
                            dailyWeeklyImage.ImageUrl = station.ImageDirUrl + station.Content.WeeklyDealImage;
                        }
                        else
                        {
                            dailyWeeklyImage.ImageUrl = "~/images/boxtop_weekly.gif";
                        }
                    }

                    dailyWeeklyImageHolder.Controls.Add(dailyWeeklyImage);

                    DollarSaverDB.CertificateDataTable daily = certificateAdapter.GetSpecial(StationId, 1);
                    if (daily.Count == 1)
                    {
                        SpecialCert1.DisplayCertificate = daily[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, daily[0].CertificateId, PageHitType.HomePage);
                        }
                    }

                    DollarSaverDB.CertificateDataTable cert2 = certificateAdapter.GetSpecial(StationId, 2);
                    if (cert2.Count == 1)
                    {
                        SpecialCert2.DisplayCertificate = cert2[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, cert2[0].CertificateId, PageHitType.HomePage);
                        }
                    }

                    DollarSaverDB.CertificateDataTable cert3 = certificateAdapter.GetSpecial(StationId, 3);
                    if (cert3.Count == 1)
                    {
                        SpecialCert3.DisplayCertificate = cert3[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, cert3[0].CertificateId, PageHitType.HomePage);
                        }
                    }

                    DollarSaverDB.CertificateDataTable cert4 = certificateAdapter.GetSpecial(StationId, 4);
                    if (cert4.Count == 1)
                    {
                        SpecialCert4.DisplayCertificate = cert4[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, cert4[0].CertificateId, PageHitType.HomePage);
                        }
                    }

                    if (!station.Content.IsOtherDealsImageNull() && File.Exists(ImageDir + station.Content.OtherDealsImage))
                    {
                        otherDealsImage.ImageUrl = station.ImageDirUrl + station.Content.OtherDealsImage;
                    }

                    if (!station.Content.IsLogoImageNull() && File.Exists(ImageDir + station.Content.LogoImage))
                    {
                        logoImage.ImageUrl = station.ImageDirUrl + station.Content.LogoImage;
                    }
                }
                else     // Deal of the Week
                {
                    standardHolder.Visible = false;
                    dealHolder.Visible     = true;

                    if (!Station.IsSiteNameNull() && Station.SiteName != String.Empty)
                    {
                        dotwStationNameLabel.Text = Regex.Replace(Station.SiteName, "<[^>]+>", "");
                    }
                    else
                    {
                        dotwStationNameLabel.Text = "DollarSaver Deal of the Week";
                    }

                    if (!Station.Content.IsDotwSubheaderImageNull() && File.Exists(ImageDir + station.Content.DotwSubheaderImage))
                    {
                        subheaderCell.Style["background-image"] = "url(" + station.ImageDirUrl + station.Content.DotwSubheaderImage + ")";
                    }
                    else
                    {
                        subheaderCell.Style["background-image"] = "url(" + ResolveUrl("~/images/dotw_background.gif") + ")";
                    }

                    DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCurrentDeal(StationId);

                    if (certificateTable.Count == 1)
                    {
                        dealOfTheWeek.Deal = certificateTable[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, certificateTable[0].CertificateId, PageHitType.HomePage);
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            saveButton.Click   += new EventHandler(saveButton_Click);
            cancelButton.Click += new EventHandler(cancelButton_Click);


            if (Station.SiteTypeId != (int)SiteType.Standard)
            {
                Response.Redirect("~/admin/Default.aspx");
            }

            specialTable = specialAdapter.GetStationSpecial(StationId, 1);
            if (specialTable.Count == 1)
            {
                specialOne = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 2);
            if (specialTable.Count == 1)
            {
                specialTwo = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 3);
            if (specialTable.Count == 1)
            {
                specialThree = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 4);
            if (specialTable.Count == 1)
            {
                specialFour = specialTable[0];
            }

            if (!Page.IsPostBack)
            {
                CategoryTableAdapter            categoryAdapter = new CategoryTableAdapter();
                DollarSaverDB.CategoryDataTable categories      = categoryAdapter.GetPrimaryCategoriesByStation(StationId);

                CertificateTableAdapter            certificateAdapter = new CertificateTableAdapter();
                DollarSaverDB.CertificateDataTable certificates       = certificateAdapter.GetActive(StationId);

                //certificates.DefaultView.Sort

                SpecialSettingsTableAdapter            specialSettingsAdapter = new SpecialSettingsTableAdapter();
                DollarSaverDB.SpecialSettingsDataTable specialSettingsTable   = specialSettingsAdapter.GetSpecialSettings(StationId);

                if (specialSettingsTable.Count == 1)
                {
                    if (specialSettingsTable[0].DailyHeader)
                    {
                        dailyWeeklyList.SelectedValue = "1";
                    }
                    else
                    {
                        dailyWeeklyList.SelectedValue = "2";
                    }
                }

                // Daily/Weekly Special 1

                /*
                 * specialOneCategoryList.DataSource = categories;
                 * specialOneCategoryList.DataTextField = "Name";
                 * specialOneCategoryList.DataValueField = "CategoryId";
                 * specialOneCategoryList.DataBind();
                 */

                specialOneCertificateList.DataSource     = certificates.Rows;
                specialOneCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialOneCertificateList.DataValueField = "CertificateId";
                specialOneCertificateList.DataBind();


                if (specialOne != null)
                {
                    if (!specialOne.IsCertificateIdNull())
                    {
                        //specialOneCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialOne.CertificateId) != null)
                        {
                            specialOneCertificateList.SelectedValue = specialOne.CertificateId.ToString();
                        }
                    }

                    /*
                     * else if (!specialOne.IsCategoryIdNull()) {
                     *  specialOneCategoryBox.Checked = true;
                     *
                     *  specialOneCategoryList.SelectedValue = specialOne.CategoryId.ToString();
                     * } else {
                     *  specialOneRandomBox.Checked = true;
                     * }
                     */
                }

                // Special 2
                specialTwoCategoryList.DataSource     = categories;
                specialTwoCategoryList.DataTextField  = "Name";
                specialTwoCategoryList.DataValueField = "CategoryId";
                specialTwoCategoryList.DataBind();

                specialTwoCertificateList.DataSource     = certificates.Rows;
                specialTwoCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialTwoCertificateList.DataValueField = "CertificateId";
                specialTwoCertificateList.DataBind();

                if (specialTwo != null)
                {
                    if (!specialTwo.IsCertificateIdNull())
                    {
                        specialTwoCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialTwo.CertificateId) != null)
                        {
                            specialTwoCertificateList.SelectedValue = specialTwo.CertificateId.ToString();
                        }
                    }
                    else if (!specialTwo.IsCategoryIdNull())
                    {
                        specialTwoCategoryBox.Checked = true;

                        specialTwoCategoryList.SelectedValue = specialTwo.CategoryId.ToString();
                    }
                    else
                    {
                        specialTwoRandomBox.Checked = true;
                    }
                }


                // Special 3
                specialThreeCategoryList.DataSource     = categories;
                specialThreeCategoryList.DataTextField  = "Name";
                specialThreeCategoryList.DataValueField = "CategoryId";
                specialThreeCategoryList.DataBind();

                specialThreeCertificateList.DataSource     = certificates.Rows;
                specialThreeCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialThreeCertificateList.DataValueField = "CertificateId";
                specialThreeCertificateList.DataBind();

                if (specialThree != null)
                {
                    if (!specialThree.IsCertificateIdNull())
                    {
                        specialThreeCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialThree.CertificateId) != null)
                        {
                            specialThreeCertificateList.SelectedValue = specialThree.CertificateId.ToString();
                        }
                    }
                    else if (!specialThree.IsCategoryIdNull())
                    {
                        specialThreeCategoryBox.Checked = true;

                        specialThreeCategoryList.SelectedValue = specialThree.CategoryId.ToString();
                    }
                    else
                    {
                        specialThreeRandomBox.Checked = true;
                    }
                }

                // Special 4
                specialFourCategoryList.DataSource     = categories;
                specialFourCategoryList.DataTextField  = "Name";
                specialFourCategoryList.DataValueField = "CategoryId";
                specialFourCategoryList.DataBind();

                specialFourCertificateList.DataSource     = certificates.Rows;
                specialFourCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialFourCertificateList.DataValueField = "CertificateId";
                specialFourCertificateList.DataBind();

                if (specialFour != null)
                {
                    if (!specialFour.IsCertificateIdNull())
                    {
                        specialFourCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialFour.CertificateId) != null)
                        {
                            specialFourCertificateList.SelectedValue = specialFour.CertificateId.ToString();
                        }
                    }
                    else if (!specialFour.IsCategoryIdNull())
                    {
                        specialFourCategoryBox.Checked = true;

                        specialFourCategoryList.SelectedValue = specialFour.CategoryId.ToString();
                    }
                    else
                    {
                        specialFourRandomBox.Checked = true;
                    }
                }
            }
        }
        void saveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                StationTableAdapter stationAdapter = new StationTableAdapter();

                String name          = nameBox.Text.Trim();
                int    siteTypeId    = Int32.Parse(siteTypeList.SelectedValue);
                int    stationTypeId = Int32.Parse(stationTypeList.SelectedValue);
                String phoneNumber   = phoneNumberBox.Text.Trim();
                String address1      = address1Box.Text.Trim();
                String address2      = address2Box.Text.Trim();
                String city          = cityBox.Text.Trim();
                String stateCode     = stateList.SelectedValue;
                String zipCode       = zipCodeBox.Text.Trim();
                int    timeZoneId    = Int32.Parse(timeZoneList.SelectedValue);
                //bool affectedByDST = daylightSavingsBox.Checked;
                String stationUrl = stationUrlBox.Text.Trim();
                String siteName   = siteNameBox.Text.Trim();
                String content1   = content1Box.Text.Trim();
                String content2   = content2Box.Text.Trim();
                //bool isActive = isActiveBox.Checked;

                if (name == String.Empty)
                {
                    ErrorMessage = "Name is required";
                    return;
                }


                if (phoneNumber == String.Empty)
                {
                    ErrorMessage = "Phone Number is required";
                    return;
                }

                if (address1 == String.Empty)
                {
                    ErrorMessage = "Address 1 is required";
                    return;
                }

                if (city == String.Empty)
                {
                    ErrorMessage = "City is required";
                    return;
                }

                if (zipCode == String.Empty)
                {
                    ErrorMessage = "Zip Code is required";
                    return;
                }

                if (stationUrl != String.Empty)
                {
                    stationUrl = stationUrlStart.SelectedValue + stationUrl;

                    // come up with a better validation...
                    if (!Uri.IsWellFormedUriString(stationUrl, UriKind.Absolute))
                    {
                        ErrorMessage = "Please enter a valid Station Website";
                        return;
                    }
                }

                if (stationUrl.Length > 500)
                {
                    stationUrl = stationUrl.Substring(0, 500);
                }

                /*
                 * if (content1 == String.Empty) {
                 *  ErrorMessage = "Content 1 is required";
                 *  return;
                 * }*/

                if (content1.Length > 1000)
                {
                    content1 = content1.Substring(0, 1000);
                }


                /*
                 * if (content2 == String.Empty) {
                 *  ErrorMessage = "Content 2 is required";
                 *  return;
                 * }*/

                if (content2.Length > 1000)
                {
                    content2 = content2.Substring(0, 1000);
                }

                siteName = siteName.Replace("<br />", "");

                if (siteName.Length > 500)
                {
                    siteName = siteName.Substring(0, 500);
                }

                String siteNameCheck = Regex.Replace(siteName, "<[^>]+>", "").Replace("&nbsp;", "").Trim();

                if (siteNameCheck == String.Empty)   // only leftover formatting in site name
                {
                    siteName = String.Empty;
                }

                if (Station != null)
                {
                    Station.Name          = name;
                    Station.SiteTypeId    = Int32.Parse(siteTypeList.SelectedValue);
                    Station.StationTypeId = Int32.Parse(stationTypeList.SelectedValue);
                    Station.PhoneNumber   = phoneNumber;
                    Station.Address1      = address1;
                    Station.Address2      = address2;
                    Station.City          = city;
                    Station.StateCode     = stateList.SelectedValue;
                    Station.ZipCode       = zipCode;
                    Station.TimeZoneId    = Int32.Parse(timeZoneList.SelectedValue);
                    //Station.AffectedByDST = daylightSavingsBox.Checked;
                    if (stationUrl != String.Empty)
                    {
                        Station.StationUrl = stationUrl;
                    }
                    else
                    {
                        Station.SetStationUrlNull();
                    }

                    if (siteName != String.Empty)
                    {
                        Station.SiteName = siteName;
                    }
                    else
                    {
                        Station.SetSiteNameNull();
                    }

                    Station.Content1 = content1;
                    Station.Content2 = content2;
                    //Station.IsActive = isActiveBox.Checked;
                    Station.IsSiteActive = isSiteActiveBox.Checked;

                    stationAdapter.Update(Station);
                    InfoMessage = "Station Updated";
                }
                else
                {
                    if (IsSuperAdmin)
                    {
                        String code = codeBox.Text.Trim().ToUpper();

                        if (code == String.Empty)
                        {
                            ErrorMessage = "Code is required";
                            return;
                        }

                        if (code.Length < 3 || code.Length > 20)
                        {
                            ErrorMessage = "Code must be between 3 and 20 characters";
                            return;
                        }

                        DollarSaverDB.StationDataTable stationCodeLookup = stationAdapter.GetByCode(code);

                        if (stationCodeLookup.Count == 1 && (Station == null || stationCodeLookup[0].StationId != Station.StationId))
                        {
                            InfoMessage = "Code is already in use";
                            return;
                        }

                        int stationId = Convert.ToInt32(stationAdapter.InsertPK(name, code, stationTypeId, siteTypeId, phoneNumber, address1, address2,
                                                                                city, stateCode, zipCode, timeZoneId, false, DateTime.Now, DateTime.Now, true,
                                                                                content1, content2, Globals.ConvertToNull(stationUrl), Globals.ConvertToNull(siteName), isSiteActiveBox.Checked, null));

                        Station = stationAdapter.GetStation(stationId)[0];

                        CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();
                        categoryAdapter.Insert(stationId, null, "Restaurants & Food", 1);
                        categoryAdapter.Insert(stationId, null, "Things To Do", 2);
                        categoryAdapter.Insert(stationId, null, "Home & Garden", 3);
                        categoryAdapter.Insert(stationId, null, "Health & Beauty", 4);
                        categoryAdapter.Insert(stationId, null, "Retail", 5);
                        categoryAdapter.Insert(stationId, null, "Automotive", 6);

                        StationContentTableAdapter stationContentTableAdapter = new StationContentTableAdapter();
                        stationContentTableAdapter.Insert(stationId, null, null, null, null, null, null, null, null, null);

                        DealSettingsTableAdapter dealSettingsAdapter = new DealSettingsTableAdapter();
                        dealSettingsAdapter.Insert(stationId, 1, 8, 4, 10);

                        SpecialSettingsTableAdapter specialSettingAdapter = new SpecialSettingsTableAdapter();
                        specialSettingAdapter.Insert(stationId, true);

                        if (!Directory.Exists(Request.PhysicalApplicationPath + Station.StationDirUrl))
                        {
                            Directory.CreateDirectory(Request.PhysicalApplicationPath + Station.StationDirUrl);
                        }

                        if (!Directory.Exists(Request.PhysicalApplicationPath + Station.ImageDirUrl))
                        {
                            Directory.CreateDirectory(Request.PhysicalApplicationPath + Station.ImageDirUrl);
                        }
                    }
                }

                RedirectToHomePage();
            }
        }
        void saveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                specialTable = new DollarSaverDB.StationSpecialDataTable();

                bool specialOneNew = false;
                if (specialOne == null)
                {
                    specialOneNew        = true;
                    specialOne           = specialTable.NewStationSpecialRow();
                    specialOne.StationId = StationId;
                    specialOne.SeqNo     = 1;
                }

                bool specialTwoNew = false;
                if (specialTwo == null)
                {
                    specialTwoNew        = true;
                    specialTwo           = specialTable.NewStationSpecialRow();
                    specialTwo.StationId = StationId;
                    specialTwo.SeqNo     = 2;
                }

                bool specialThreeNew = false;
                if (specialThree == null)
                {
                    specialThreeNew        = true;
                    specialThree           = specialTable.NewStationSpecialRow();
                    specialThree.StationId = StationId;
                    specialThree.SeqNo     = 3;
                }

                bool specialFourNew = false;
                if (specialFour == null)
                {
                    specialFourNew        = true;
                    specialFour           = specialTable.NewStationSpecialRow();
                    specialFour.StationId = StationId;
                    specialFour.SeqNo     = 4;
                }

                // Special One
                //if (specialOneCertificateBox.Checked) {
                bool dailyHeader = false;
                if (dailyWeeklyList.SelectedValue == "1")
                {
                    dailyHeader = true;
                }

                SpecialSettingsTableAdapter            specialSettingsAdapter = new SpecialSettingsTableAdapter();
                DollarSaverDB.SpecialSettingsDataTable specialSettingsTable   = specialSettingsAdapter.GetSpecialSettings(StationId);

                if (specialSettingsTable.Count == 1)
                {
                    specialSettingsTable[0].DailyHeader = dailyHeader;
                    specialSettingsAdapter.Update(specialSettingsTable[0]);
                }
                else
                {
                    specialSettingsAdapter.Insert(StationId, dailyHeader);
                }

                specialOne.CertificateId = Convert.ToInt32(specialOneCertificateList.SelectedValue);
                specialOne.SetCategoryIdNull();

                /*
                 * } else if (specialOneCategoryBox.Checked) {
                 *  specialOne.CategoryId = Convert.ToInt32(specialOneCategoryList.SelectedValue);
                 *  specialOne.SetCertificateIdNull();
                 * } else {
                 *  specialOne.SetCertificateIdNull();
                 *  specialOne.SetCategoryIdNull();
                 * }
                 * */

                if (specialOneNew)
                {
                    specialTable.AddStationSpecialRow(specialOne);
                }
                else
                {
                    specialTable.ImportRow(specialOne);
                }

                // Special Two
                if (specialTwoCertificateBox.Checked)
                {
                    specialTwo.CertificateId = Convert.ToInt32(specialTwoCertificateList.SelectedValue);
                    specialTwo.SetCategoryIdNull();
                }
                else if (specialTwoCategoryBox.Checked)
                {
                    specialTwo.CategoryId = Convert.ToInt32(specialTwoCategoryList.SelectedValue);
                    specialTwo.SetCertificateIdNull();
                }
                else
                {
                    specialTwo.SetCertificateIdNull();
                    specialTwo.SetCategoryIdNull();
                }

                if (specialTwoNew)
                {
                    specialTable.AddStationSpecialRow(specialTwo);
                }
                else
                {
                    specialTable.ImportRow(specialTwo);
                }

                // Special Three
                if (specialThreeCertificateBox.Checked)
                {
                    specialThree.CertificateId = Convert.ToInt32(specialThreeCertificateList.SelectedValue);
                    specialThree.SetCategoryIdNull();
                }
                else if (specialThreeCategoryBox.Checked)
                {
                    specialThree.CategoryId = Convert.ToInt32(specialThreeCategoryList.SelectedValue);
                    specialThree.SetCertificateIdNull();
                }
                else
                {
                    specialThree.SetCertificateIdNull();
                    specialThree.SetCategoryIdNull();
                }

                if (specialThreeNew)
                {
                    specialTable.AddStationSpecialRow(specialThree);
                }
                else
                {
                    specialTable.ImportRow(specialThree);
                }

                // Special Four
                if (specialFourCertificateBox.Checked)
                {
                    specialFour.CertificateId = Convert.ToInt32(specialFourCertificateList.SelectedValue);
                    specialFour.SetCategoryIdNull();
                }
                else if (specialFourCategoryBox.Checked)
                {
                    specialFour.CategoryId = Convert.ToInt32(specialFourCategoryList.SelectedValue);
                    specialFour.SetCertificateIdNull();
                }
                else
                {
                    specialFour.SetCertificateIdNull();
                    specialFour.SetCategoryIdNull();
                }

                if (specialFourNew)
                {
                    specialTable.AddStationSpecialRow(specialFour);
                }
                else
                {
                    specialTable.ImportRow(specialFour);
                }



                specialAdapter.Update(specialTable);

                InfoMessage = "Specials updated";
                Response.Redirect("~/admin/Default.aspx");
            }
        }
        private void GenerateFeed()
        {
            CertificateTableAdapter certificateAdapter = new CertificateTableAdapter();


            String description = "";

            String siteUrl     = "http://" + EnvDomain;
            String homePageUrl = siteUrl + ResolveUrl("~/Default.aspx") + "?station_id=" + StationId;

            //mainFeed.Title = TextSyndicationContent.CreatePlaintextContent(Station.SiteNamePlainText);
            //mainFeed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(homePageUrl)));


            List <DollarSaverDB.CertificateRow> listCertificates = new List <DollarSaverDB.CertificateRow>();

            if (Station.StationSiteType == SiteType.Standard)
            {
                SpecialSettingsTableAdapter            specialSettingsAdapter = new SpecialSettingsTableAdapter();
                DollarSaverDB.SpecialSettingsDataTable specialSettingsTable   = specialSettingsAdapter.GetSpecialSettings(StationId);

                bool dailyHeader = false;
                if (specialSettingsTable.Count == 1)
                {
                    dailyHeader = specialSettingsTable[0].DailyHeader;
                }

                if (dailyHeader)
                {
                    description = "Daily Deal";
                }
                else
                {
                    description = "Weekly Deal";
                }

                DollarSaverDB.CertificateDataTable daily = certificateAdapter.GetSpecial(StationId, 1);
                if (daily.Count == 1)
                {
                    listCertificates.Add(daily[0]);
                }
            }
            else
            {
                description = "Deal of the Week";

                DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCurrentDeal(StationId);

                if (certificateTable.Count == 1)
                {
                    listCertificates.Add(certificateTable[0]);
                }
            }

            List <SyndicationItem> items = new List <SyndicationItem>();

            foreach (DollarSaverDB.CertificateRow certificate in listCertificates)
            {
                SyndicationItem item = new SyndicationItem();

                item.Title = TextSyndicationContent.CreatePlaintextContent(certificate.AdvertiserName);

                String advertiserUrl = siteUrl + ResolveUrl("~/Advertiser.aspx?advertiser_id=" + certificate.AdvertiserId);

                item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(advertiserUrl)));


                StringBuilder content = new StringBuilder();


                if (certificate.Advertiser.LogoUrl != String.Empty)
                {
                    String logoUrl = siteUrl + ResolveUrl(certificate.Advertiser.LogoUrl);

                    int logoWidth  = 125;
                    int logoHeight = 75;

                    if (certificate.Advertiser.IsLogoImageVertical)
                    {
                        logoWidth  = 75;
                        logoHeight = 125;
                    }

                    content.Append("<div>");
                    content.Append("<a href=\"" + advertiserUrl + "\">");
                    content.Append("<img src=\"" + logoUrl + "\"  alt=\"" + Server.HtmlEncode(certificate.AdvertiserName) + "\" style=\"border-color:#404040;border-width:1px;border-style:solid;height:" + logoHeight + "px;width:" + logoWidth + "px;\">");
                    content.Append("</a>");
                    content.Append("</div>");
                }

                content.Append("<div style=\"font-family: Arial;\">");

                //content.Append("<a href=\"" + advertiserUrl + "\" style=\"font-weight: bold; font-size: 1.3em; line-height: 1.7em;\">" + Server.HtmlEncode(certificate.AdvertiserName) + "</a>");

                content.Append("<p>");
                content.Append(certificate.Advertiser.Description);
                content.Append("</p>");
                content.Append("<a href=\"" + advertiserUrl + "\" style=\"font-weight: bold; font-size: 1.1em; line-height: 1.5em;\">" + Server.HtmlEncode(certificate.ShortName) + "<a>");
                content.Append("<p> ");
                content.Append(certificate.Description);
                content.Append("</p>");
                content.Append("<p style=\"font-weight: bold;\"> ");
                content.Append("Certificate Value: " + certificate.FaceValue.ToString("$0.00") + "<br />");
                content.Append("Price: <span style=\"color: red;\">" + certificate.DiscountValue.ToString("$0.00") + "</span><br />");
                content.Append("Your Savings: " + certificate.Savings + "<br />");
                content.Append("</p>");
                content.Append("<a href=\"" + advertiserUrl + "\" style=\"font-weight: bold; font-size: 1.1em; line-height: 1.5em;\">BUY NOW</a>");
                content.Append("</div>");
                content.Append("<div style=\"clear: both;\"></div>");


                item.Content = SyndicationContent.CreateHtmlContent(content.ToString());

                items.Add(item);
            }


            SyndicationFeed mainFeed = new SyndicationFeed(Station.SiteNamePlainText, description, new Uri(homePageUrl));

            mainFeed.Description = TextSyndicationContent.CreatePlaintextContent(description);

            mainFeed.Items = items;

            Response.ContentType = "application/rss+xml";

            using (XmlWriter xmlWriter = XmlWriter.Create(Response.OutputStream)) {
                Rss20FeedFormatter rssFeed = new Rss20FeedFormatter(mainFeed);
                rssFeed.WriteTo(xmlWriter);
            }
        }