Example #1
0
        public static List <CalendarItem> GetCalendarItems(Calender calender, LiveTilesContext db)
        {
            // Now the items for this week

            var sunday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek);
            //This subtracting the current Day of week (0 for Sunday, 1 for Monday etc) from today
            var endOfweek = sunday.AddDays(7);
            //This adding 7 days to the date of sunday to get the end of this week.

            // Get all the calendar items for this calendar for this week
            var calendarItems = db.CalendarItem.Where(
                a => a.CalendarId == calender.TileId && a.StartTime > sunday && a.EndTime < endOfweek).Select(a => a).ToList();


            return(calendarItems);
        }
Example #2
0
        public static NoticeboardItem GetNoticeboardItem(Noticeboard noticeBoard, LiveTilesContext db)
        {
            // This is a noticeboard tile. Get the item to display using the current item count.
            // Searches through all Noticeboard Items for those belonging to this Noticeboard.
            var tileItems = db.NoticeboardItem.Where(a => a.NoticeboardId == noticeBoard.TileId).Select(a => a).ToList();

            if (tileItems.Count == 0)
            {
                return(null);
            }

            var tileItem = tileItems[noticeBoard.CurrentItem];

            // cycle around the items to display
            noticeBoard.CurrentItem++;
            if (noticeBoard.CurrentItem == tileItems.Count)
            {
                noticeBoard.CurrentItem = 0;
            }
            return(tileItem);
        }