public IActionResult Index()
        {
            var m = new Dashboard()
            {
                AvailableWidgets  = _widgetProvider.LoadWidgets(),
                SupportedStations = new Dictionary <System.Guid, IEnumerable <PublicStationData> >()
            };

            foreach (var widget in m.AvailableWidgets)
            {
                if (User.Identity.IsAuthenticated)
                {
                    m.SupportedStations.Add(widget.Guid, _widgetProvider.GetSupportedStations(widget).Select(s => s.ToPublicStationData()));
                }
                else
                {
                    m.SupportedStations.Add(widget.Guid, _widgetProvider.GetSupportedPublicStations(widget).Select(s => s.ToPublicStationData()));
                }
            }

            if (User.Identity.IsAuthenticated)
            {
                using (var db = new WeatherDb())
                {
                    LoadDashboardFromDatabase(db, ref m);
                }
            }
            else
            {
                LoadDashboardFromSession(ref m);
            }

            return(View(m));
        }
Example #2
0
        IEnumerable <WeatherStation> GetSupportedStations(Models.Widget widget)
        {
            IEnumerable <WeatherStation> supportedStations;

            if (_context.HttpContext.User.Identity.IsAuthenticated)
            {
                supportedStations = _widgetProvider.GetSupportedStations(widget);
            }
            else
            {
                supportedStations = _widgetProvider.GetSupportedPublicStations(widget);
            }

            return(supportedStations);
        }