Ejemplo n.º 1
0
        public static HistoryEntity Previous()
        {
            var cur_entity = cur_index >= 1 ? HistoryList.ElementAt(cur_index - 1) : null;

            if (cur_entity != null)
            {
                cur_index -= 1;
            }

            return(cur_entity);
        }
Ejemplo n.º 2
0
        public static HistoryEntity Next()
        {
            var cur_entity = cur_index < HistoryList.Count - 1 ? HistoryList.ElementAt(cur_index + 1) : null;

            if (cur_entity != null)
            {
                cur_index += 1;
            }

            return(cur_entity);
        }
Ejemplo n.º 3
0
        public HistoryViewModel()
        {
            using (var context = new EventDatabaseEntities())
            {
                int CurrentIndex = 0;
                // Get every date when was an event.
                var dates = context.Events.Where(x => DbFunctions.TruncateTime(x.Date) < DateTime.Today)
                            .GroupBy(r => DbFunctions.TruncateTime(r.Date)).OrderByDescending(x => x.Key).ToList();

                // Set the date indicators.
                ToDate   = dates.ElementAt(0).Key.ToString();
                FromDate = dates.ElementAt(dates.Count() - 1).Key.ToString();

                foreach (var events in dates)
                {
                    // Every event that happend at this day.
                    var Events = context.Events.Where(x => DbFunctions.TruncateTime(x.Date) == events.Key).ToList();

                    // Add the date to the list.
                    HistoryList.Add(new HistoryModel()
                    {
                        EventDate = (DateTime)events.Key
                    });

                    // Get the tasks for the events if there any.
                    foreach (var task in Events)
                    {
                        var tasks = context.Tasks.Where(x => x.EventID == task.ID).ToList();
                        HistoryList.ElementAt(CurrentIndex).EventList.Add(new HistoryListModel(task, tasks));
                    }

                    CurrentIndex++;
                }
            }

            DateFilterCommand  = new RelayCommand(DateFilterEvent);
            DeleteEventCommand = new RelayParamCommand <Event>(DeleteEvent);
            CloseEventCommand  = new RelayCommand(CloseEvent);
        }