Beispiel #1
0
        private void insertNewTimeEntryGroup(IThreadSafeTimeEntry timeEntry, DateTime indexDate)
        {
            var timeEntryToAdd = new TimeEntryViewModel(timeEntry, durationFormat);
            var newCollection  = new TimeEntryViewModelCollection(indexDate, new[] { timeEntryToAdd }, durationFormat);
            var foundIndex     = TimeEntries.IndexOf(TimeEntries.FirstOrDefault(x => x.Date < indexDate));
            var indexToInsert  = foundIndex == -1 ? TimeEntries.Count : foundIndex;

            TimeEntries.Insert(indexToInsert, newCollection);
        }
Beispiel #2
0
        private void onTimeEntryCreated(IDatabaseTimeEntry timeEntry)
        {
            var indexDate        = timeEntry.Start.Date;
            var timeEntriesInDay = new List <TimeEntryViewModel> {
                new TimeEntryViewModel(timeEntry)
            };

            var collection = TimeEntries.FirstOrDefault(x => x.Date == indexDate);

            if (collection != null)
            {
                timeEntriesInDay.AddRange(collection);
                TimeEntries.Remove(collection);
            }

            var newCollection = new TimeEntryViewModelCollection(indexDate, timeEntriesInDay.OrderByDescending(te => te.Start));

            var foundIndex    = TimeEntries.IndexOf(TimeEntries.FirstOrDefault(x => x.Date < indexDate));
            var indexToInsert = foundIndex == -1 ? TimeEntries.Count : foundIndex;

            TimeEntries.Insert(indexToInsert, newCollection);

            RaisePropertyChanged(nameof(IsEmpty));
        }