Beispiel #1
0
        public MenuModel CreateMenu()
        {
            var menu = new MenuModel();

            _getProjectOverviewQuery.ActiveProjectsOnly = true;
            _getProjectOverviewQuery.WithSeries         = true;

            var projects = _getProjectOverviewQuery.Handle();

            foreach (var project in projects)
            {
                // Only use projects with active series
                var serieItems = project.SerieItems.Where(s => s.Published <= DateTime.Now || !s.Published.HasValue);

                // Don't show projects without any active series.
                if (!serieItems.Any())
                {
                    continue;
                }

                var menuItem = new MenuItem();
                menuItem.Id         = project.Id;
                menuItem.Name       = project.Name;
                menuItem.Rank       = project.Rank;
                menuItem.UniqueName = project.UniqueName;

                if (serieItems.Count() > 1)
                {
                    menuItem.MenuItems = from s in serieItems
                                         select new MenuItem
                    {
                        Id         = s.Id,
                        Name       = s.Name,
                        Rank       = s.Rank,
                        UniqueName = s.UniqueName
                    };
                }
                else
                {
                    menuItem.Name       = serieItems.First().Name;
                    menuItem.UniqueName = serieItems.First().UniqueName;
                }

                menu.MenuItems.Add(menuItem);
            }

            return(menu);
        }
Beispiel #2
0
        public ActionResult Index()
        {
            var model = _getProjectOverviewQuery.Handle();

            return(View(model));
        }