//private readonly ISitecoreService _sitecoreService; //public TeamController(ISitecoreService sitecoreService) //{ // _sitecoreService = sitecoreService ?? throw new ArgumentNullException(nameof(sitecoreService)); //} // GET: Hackathons public PartialViewResult Team() { var sc = new SitecoreContext(); var item = Context.Database.GetItem($"/sitecore/content/hackathon/Hackathons{Request.Path.Replace("-", " ")}"); var model = sc.Cast <Team>(item); model.TeamMembers = new List <TeamMember>(); foreach (Sitecore.Data.Items.Item c in item.Children) { model.TeamMembers.Add(sc.Cast <TeamMember>(c)); } return(PartialView(model)); }
public override void Initialize(Rendering rendering) { base.Initialize(rendering); var glassService = new SitecoreContext(); // Set Current Site's Home Page Item HomePage = glassService.Cast <CoreInferred>(DatabaseContext.GetItem(Sitecore.Context.Site.StartPath), true, true) as CoreHome; if (HomePage == null || !HomePage.Children.Any()) { return; } // Fill First level of content pages ContentPages = HomePage.Children.OfType <CoreFolder>().ToList(); // Fill the Micro Sites var microSiteFolders = HomePage.Children.OfType <SiteFolder>().ToList(); if (!microSiteFolders.Any()) { return; } // Get home pages under Site Folder MicroSites = microSiteFolders.SelectMany( f => f.Children.OfType <CoreHome>(), (f, c) => c ).ToList(); }
public ActionResult GetShowsForToday() { var list = new List <PlanEvent>(); var sc = new SitecoreContext(); var itemBuckets = Sitecore.Configuration.Factory.GetDatabase("master").GetItem("/sitecore/content/EPG/Sections/PlanBuckets/AsiaPlan/"); if (itemBuckets != null && BucketManager.IsBucket(itemBuckets)) { using (var searchContext = ContentSearchManager.GetIndex("sitecore_master_index").CreateSearchContext()) { var result = searchContext.GetQueryable <SearchResultItem>().Where(x => x.Path.Contains("Sections/PlanBuckets/AsiaPlan/") && x.TemplateId == new ID("{50B06575-9906-4B50-8E63-3E8BBEF1F858}")); if (result != null) { foreach (var item in result) { list.Add(sc.Cast <PlanEvent>(item.GetItem())); } } } } if (list.Count > 0) { string today = DateTime.Now.ToString("dd/MM/yyyy");//9/1/2015" // today = "01/12/2017"; //get shows after today 12:00 AM IEnumerable <PlanEvent> elist = list.Where(x => DateTime.ParseExact(x.BroadcastDate, "dd/MM/yyyy", null).CompareTo(DateTime.ParseExact(today, "dd/MM/yyyy", null)) > 0); list = new List <PlanEvent>(elist); //sort them in ascending list.Sort((date1, date2) => DateTime.ParseExact(date1.BroadcastDate + " " + date1.PlanTime, "dd/MM/yyyy HH:mm", null).CompareTo(DateTime.ParseExact(date2.BroadcastDate + " " + date2.PlanTime, "dd/MM/yyyy HH:mm", null))); int a = list.Count; } return(View(list)); }
public T GetItem(Item item) { using (var context = new SitecoreContext()) { return(context.Cast <T>(item)); } }
protected T GetItem <T>(Item item) where T : class { using (var context = new SitecoreContext()) { return(context.Cast <T>(item)); } }
public ActionResult MainNavigation() { var items = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath).Children .Select(c => SitecoreContext.Cast <IBasePage>(c)) .Where(c => c.Active && c.Display_In_Menu); return(PartialView(items)); }
public override void Initialize(Rendering rendering) { base.Initialize(rendering); var contextItem = Rendering.Item; // AE.Core.PageContext.Current.DataItem var glassService = new SitecoreContext(); Inferred = glassService.Cast <CoreInferred>(contextItem, true, true); }
public ActionResult FooterNavigation() { Item item = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.RootPath)?.Children .FirstOrDefault(c => c.TemplateID == ISiteDataFolderConstants.TemplateId)?.Children .FirstOrDefault(c => c.TemplateID == ISettingsFolderConstants.TemplateId)?.Children .FirstOrDefault(c => c.TemplateID == IFooterSettingsConstants.TemplateId); FooterSettingsVM vm = new FooterSettingsVM(SitecoreContext.Cast <IFooterSettings>(item)); return(PartialView(vm)); }
protected virtual TModel GetModel() { if (RenderingContext.HasDataSource) { return(SitecoreContext.Cast <TModel>(DataSourceItem)); } else { return(SitecoreContext.Cast <TModel>(ContextItem)); } }
public ActionResult Promotion() { Item current = SitecoreContext.GetCurrentItem <Item>(); IPromotion model = SitecoreContext.GetCurrentItem <IPromotion>(); model.Version = current.Version.Number; model.Updated = current.Statistics.Updated; model.Parent = current.Parent; //Make sure there is work to do if (model.IncludeTags != null) { //create dictionary model.IncludedItems = new Dictionary <string, List <Item> >(); Item home = SitecoreContext.GetHomeItem <Item>(); ChildList sections = home.GetChildren(); foreach (Item section in sections) { model.IncludedItems.Add(section.DisplayName, new List <Item>()); } //get database Database database = Sitecore.Configuration.Factory.GetDatabase("web"); //get items of type content and sort by display name List <Item> allItems = database.SelectItems("/sitecore/Content/Home/*/*").Where(x => x.TemplateID == Constants.Templates.Content).OrderBy(x => x.DisplayName).ToList(); //find items that match include tags for the current item foreach (Item itm in allItems) { IContent tmpItm = SitecoreContext.Cast <IContent>(itm); IEnumerable <Guid> tmpTags = tmpItm.Tags?.Select(x => x.ID); if (tmpTags != null && tmpTags.Any()) { foreach (ITag tag in model.IncludeTags) { if (tmpTags.Contains(tag.ID)) { model.IncludedItems[tmpItm.Parent.DisplayName.ToString()].Add(itm); } } } } } return(View("~/Views/UsaCjj/Promotion.cshtml", model)); }
public ViewResult FooterLinks() { var model = new FooterLinks(); var footerlinksOther = new List <MenuLink>(); var footerlinks = _sitecoreContext.Database.GetItem(new ID(Consts.Ids.FooterLinks)); foreach (MenuLink footer in footerlinks.Children.Select(c => _sitecoreContext.Cast <MenuLink>(c))) { if (Guid.Parse(Consts.Ids.FooterLinksDisclosure).Equals(footer.Id)) { model.Disclosure = footer; } else { footerlinksOther.Add(footer); } } model.Footerlink = footerlinksOther; return(View(model)); }
/// <summary> /// Returns the Layout Item as strongly typed /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public T GetLayoutItem <T>(bool isLazy = false, bool inferType = false) where T : class { return(SitecoreContext.Cast <T>(LayoutItem, isLazy, inferType)); }
public ActionResult ImageOverlay() { return(View(ContextItem == null ? null : SitecoreContext.Cast <IPage>(ContextItem))); }
protected virtual TModel GetModel() { return(SitecoreContext.Cast <TModel>(LayoutItem)); }