/// <summary> /// Gives back all the widgets for monitoring activities /// </summary> public IEnumerable <Widget> GetWidgetsForActivities(int platformId) { InitRepo(); //Get widgets IEnumerable <Widget> widgets = widgetRepo.ReadActivityWidgets().AsEnumerable(); if (widgets == null || widgets.Count() == 0) { return(widgets); } //Check lastUpdated DateTime?lastUpdated = new SubplatformManager().GetSubPlatform(platformId).LastUpdatedActivities; //If lastUpdated was to long ago, then the activities shall be udpated if (lastUpdated == null || !lastUpdated.Value.ToString("dd-MM-yy").Equals(DateTime.Now.ToString("dd-MM-yy"))) { widgets = ChangeWidgetActities(widgets, platformId); } //Link widdatas to widgets foreach (Widget widget in widgets) { widget.WidgetDatas.ToList().AddRange(GetWidgetDatasForWidgetId(widget.WidgetId)); } return(widgets); }