/// <summary>
        /// Displays the list of closures as HTML
        /// </summary>
        /// <param name="date">The date.</param>
        /// <returns></returns>
        public async Task <ActionResult> Index(string date)
        {
            var model = new SchoolClosuresViewModel()
            {
                ShowPlannedClosures = false, ShowEmergencyClosures = true
            };

            // This page displays closures for a specific day. By default, that's today, but can be set to a different day.
            model.TargetDay = TargetDayForClosures(date, DateTime.Now.ToUkDateTime());

            model.Metadata.Title = BuildPageTitle(model);

            // If the date is in the past, the closures won't be listed any more so we want to return a
            // response that'll tell search engines not to list this page
            if (model.TargetDay < DateTime.Today)
            {
                new HttpStatus().Gone();
            }

            IServiceClosureData closureData = await LoadClosureData();

            if (closureData != null && closureData.EmergencyClosureExists(model.TargetDay.Value))
            {
                // Get all schools from the XML and add them to the list.
                // List has the TargetDate set which filters the data
                var allServices = closureData.Services();
                foreach (var service in allServices)
                {
                    service.Url = PrepareAbsoluteUrl(SchoolUrl.FormatSchoolUrl(service.Code).ToString());
                    model.Services.Add(service);
                }
            }

            // Support the website template
            var templateRequest = new EastSussexGovUKTemplateRequest(Request);

            try
            {
                model.WebChat = await templateRequest.RequestWebChatSettingsAsync();
            }
            catch (Exception ex)
            {
                // Failure to get webchat settings should be reported, but should not cause the page to fail
                ex.ToExceptionless().Submit();
            }
            try
            {
                model.TemplateHtml = await templateRequest.RequestTemplateHtmlAsync();
            }
            catch (Exception ex)
            {
                // Failure to get the template should be reported, but should not cause the page to fail
                ex.ToExceptionless().Submit();
            }

            return(View(model));
        }
        public async Task <ActionResult> Rss(string service)
        {
            var model = new RssViewModel();

            // Get the data on schools service closures
            var closureData = await LoadClosureData();

            var nav = (closureData as XPathDocument).CreateNavigator();

            nav.MoveToRoot();
            model.ClosureXml = nav.OuterXml;

            model.StylesheetFilename = HostingEnvironment.MapPath("~/App_Data/ClosuresRss.xslt");

            // Configure the XSLT transform.
            // Date in RFC 822 format is for whenever a date is included in RSS data
            // Date in ISO 8601 format us used to filter the closure data which has expired
            model.Parameters.Add("Rfc822Date", DateTime.Now.ToRfc822DateTime());
            model.Parameters.Add("Iso8601Date", DateTime.Now.ToIso8601DateTime());
            model.Parameters.Add("CurrentUrl", PrepareAbsoluteUrl(Request.Url.PathAndQuery).ToString());
            model.Parameters.Add("HtmlXsltUrl", PrepareAbsoluteUrl(Url.Content("~/eastsussexgovuk/rss/rss-to-html.ashx")).ToString());
            model.Parameters.Add("CssUrl", PrepareAbsoluteUrl(Url.Content("~/eastsussexgovuk/rss/rss.css")).ToString());
            model.Parameters.Add("ImageUrl", PrepareAbsoluteUrl(Url.Content("~/eastsussexgovuk/rss/escc-logo-for-feed.gif")).ToString());

            var serviceUrlStart = PrepareAbsoluteUrl(SchoolUrl.FormatSchoolUrl("{0}").ToString()) + ConfigurationManager.AppSettings["RssCampaignTracking"];
            var codeIndex       = serviceUrlStart.IndexOf("{0}", StringComparison.OrdinalIgnoreCase);

            if (codeIndex > -1)
            {
                model.Parameters.Add("ServiceUrlAfterCode", serviceUrlStart.Substring(codeIndex + 3));
                serviceUrlStart = serviceUrlStart.Substring(0, codeIndex);
            }
            model.Parameters.Add("ServiceUrlBeforeCode", serviceUrlStart);

            // If the feed is for a single school, get the URL of the school's page.
            // Otherwise use the school closures page.
            if (!String.IsNullOrEmpty(Request.QueryString["service"]))
            {
                model.Parameters.Add("ServiceCode", Request.QueryString["service"]); // expects school code, for example 8454045;

                model.Parameters.Add("XhtmlVersionUrl", PrepareAbsoluteUrl(SchoolUrl.FormatSchoolUrl(service).ToString()).ToString());
            }
            else
            {
                model.Parameters.Add("XhtmlVersionUrl", PrepareAbsoluteUrl(Url.Content("~/")).ToString());
            }

            return(View(model));
        }