using System; using System.Linq; using DR.FV2016.Service.Interfaces; using DR.WCMS.Web.UIBindings.Extensions; using DRCMSRedesign.Contracts; using StructureMap; namespace DR.FV2016.Web.Helpers { public static class AgentHelper { public static Agent GetAgentFromCms(string agentName, string agentContainerUrl) { if (string.IsNullOrEmpty(agentName)) throw new ArgumentNullException("agentName", "agentName cannot be null or empty, give me a name!!"); ArticleWrapper agentContent = ObjectFactory.GetInstance().GetWebCmsArticle(agentContainerUrl); return agentContent.Agents.GetAgent(agentName); } public static FocusElement GetFocusElementFromCms(string name, string articleContainerUrl) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); ArticleWrapper content = ObjectFactory.GetInstance().GetWebCmsArticle(articleContainerUrl); return content.FocusElements.FirstOrDefault(x => x.Header == name); } } }