using System; using System.Collections.Generic; using System.Configuration; using System.Web; using System.Web.Mvc; using System.Web.UI; using AutoMapper; using DR.FV2016.Service.Interfaces; using DR.FV2016.Web.Helpers; using DR.FV2016.Web.Models; using DR.Redesign.PsdbService.Service.Contract; using DR.Web.UI.Model; namespace DR.FV2016.Web.Controllers { public class FrontpageController : Controller { private readonly IPsdbService _psdbService; private readonly IArticleService _articleService; public FrontpageController(IPsdbService psdbService, IArticleService articleService) { if (psdbService == null) throw new ArgumentNullException("psdbService"); if (articleService == null) throw new ArgumentNullException("articleService"); _psdbService = psdbService; _articleService = articleService; } [OutputCache(Location = OutputCacheLocation.Downstream, Duration = 60)] public ActionResult Index() { var model = Mapper.Map(_articleService.GetWebCmsArticle("/valg2015/index")); //model.PsdbBand = GetPsdbBandList(); model.CanonicalLink = string.Format("http://www.dr.dk{0}", HttpRuntime.AppDomainAppVirtualPath); SearchableHelper.EnsureUrn(model, "urn:dr:valg2015:forside"); return View(model); } protected ArticleList GetPsdbBandList() { var list = new ArticleList(); try { var uri = ControllerContext.HttpContext.Server.MapPath(ConfigurationManager.AppSettings["NewsTvConfigurationFileName"]); var programs = _psdbService.GetCurrentLatestEpisodeInProgramSeriesForTv(uri); list.Items = Mapper.Map>(programs); } catch { // swallow, just swallow... } return list; } } }