Ejemplo n.º 1
0
        private void UpdateTimeHolders(List <TimeEntryHolder> timeHolders, TimeEntryData entry, DataAction action)
        {
            for (var i = 0; i < timeHolders.Count; i++)
            {
                if (entry.Id == timeHolders [i].Data.Id)
                {
                    if (action == DataAction.Put)
                    {
                        timeHolders [i] = new TimeEntryHolder(entry);  // Replace
                    }
                    else
                    {
                        timeHolders.RemoveAt(i);  // Remove
                    }
                    return;
                }
            }

            if (action == DataAction.Put)
            {
                timeHolders.Add(new TimeEntryHolder(entry));   // Add
            }
        }
Ejemplo n.º 2
0
 protected async override Task RemoveTimeEntryHolderAsync (TimeEntryHolder holder)
 {
     await RemoveEntryAsync (holder.TimeEntryData);
 }
        protected async override Task RemoveTimeEntryHolderAsync (TimeEntryHolder holder)
        {
            DateGroup dateGroup;
            TimeEntryGroup timeEntryGroup;
            TimeEntryData timeEntry;

            if (FindExistingEntry (holder.TimeEntryData, out dateGroup, out timeEntryGroup, out timeEntry)) {

                // Get items indexes.
                var entryGroupIndex = GetEntryGroupIndex (timeEntryGroup);
                var dateGroupIndex = GetDateGroupIndex (dateGroup);
                dateGroup.Remove (timeEntryGroup);

                // Notify removed entry group.
                await UpdateCollectionAsync (timeEntryGroup, NotifyCollectionChangedAction.Remove, entryGroupIndex);

                // Notify or update Date group.
                if (dateGroup.TimeEntryGroupList.Count == 0) {
                    dateGroups.Remove (dateGroup);
                    await UpdateCollectionAsync (dateGroup, NotifyCollectionChangedAction.Remove, dateGroupIndex);
                } else {
                    await UpdateCollectionAsync (dateGroup, NotifyCollectionChangedAction.Replace, dateGroupIndex);
                }
            }
        }
Ejemplo n.º 4
0
 protected async override Task AddTimeEntryHolderAsync (TimeEntryHolder holder)
 {
     await AddOrUpdateEntryAsync (holder.TimeEntryData);
 }
        protected async override Task AddTimeEntryHolderAsync (TimeEntryHolder holder)
        {
            var entryGroup = new TimeEntryGroup (holder.TimeEntryDataList);

            bool isNewGroup;
            DateGroup grp = GetDateGroupFor (entryGroup.Data, out isNewGroup);
            grp.Add (entryGroup);
            Sort ();

            // Update Date group.
            var groupIndex = GetDateGroupIndex (grp);
            var groupAction = isNewGroup ? NotifyCollectionChangedAction.Add : NotifyCollectionChangedAction.Replace;
            await UpdateCollectionAsync (grp, groupAction, groupIndex);

            // Add time entry group.
            var newIndex = GetEntryGroupIndex (entryGroup);
            await UpdateCollectionAsync (entryGroup, NotifyCollectionChangedAction.Add, newIndex);
        }