예제 #1
0
        private void onTimeEntryDeleted(long id)
        {
            var viewModel = TimeEntries.Select(c => c.SingleOrDefault(vm => vm.Id == id)).SingleOrDefault(vm => vm != null);

            if (viewModel == null)
            {
                return;
            }

            var collection = TimeEntries.SingleOrDefault(c => c.Date == viewModel.Start.Date);

            if (collection == null)
            {
                return;
            }

            collection.Remove(viewModel);
            var indexToInsert = TimeEntries.IndexOf(collection);

            TimeEntries.Remove(collection);

            if (collection.Count > 0)
            {
                var newCollection = new TimeEntryViewModelCollection(collection.Date.DateTime, collection);
                TimeEntries.Insert(indexToInsert, newCollection);
            }

            RaisePropertyChanged(nameof(IsEmpty));
        }
예제 #2
0
        private void onTimeEntryUpdated(IDatabaseTimeEntry timeEntry)
        {
            var collection = TimeEntries.SingleOrDefault(c => c.Date == timeEntry.Start.Date);

            if (collection == null)
            {
                return;
            }

            var viewModel = collection.SingleOrDefault(vm => vm.Id == timeEntry.Id);

            if (viewModel == null)
            {
                return;
            }

            collection.Remove(viewModel);
            RaisePropertyChanged(nameof(IsEmpty));
        }