public async Task Init() { IsLoading = true; if (timeEntryList == null) { timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(timeEntryIds); } // Create model. if (timeEntryList.Count > 1) { model = new TimeEntryGroup(timeEntryList); } else if (timeEntryList.Count == 1) { model = new TimeEntryModel(timeEntryList [0]); } await model.LoadAsync(); if (model.Workspace == null || model.Workspace.Id == Guid.Empty) { model = null; } IsLoading = false; }
public async void Init() { IsLoading = true; // Create workspace. workspace = new WorkspaceModel(workspaceId); // Create model. if (timeEntryList.Count > 1) { Model = new TimeEntryGroup(timeEntryList); } else if (timeEntryList.Count == 1) { Model = new TimeEntryModel(timeEntryList [0]); } // Load models. if (timeEntryList.Count > 1) { await Task.WhenAll(workspace.LoadAsync(), Model.LoadAsync()); } else { await workspace.LoadAsync(); } IsLoading = false; }
public async void Init() { IsLoading = true; // Create list manager. tagList = new WorkspaceTagsView(workspaceId); // Create model. if (timeEntryList.Count > 1) { Model = new TimeEntryGroup(timeEntryList); } else if (timeEntryList.Count == 1) { Model = new TimeEntryModel(timeEntryList [0]); } // Create tag list. var dataStore = ServiceContainer.Resolve <IDataStore> (); modelTags = new List <TimeEntryTagData> (); foreach (var timeEntryData in timeEntryList) { var tags = await dataStore.Table <TimeEntryTagData> () .QueryAsync(r => r.TimeEntryId == timeEntryData.Id && r.DeletedAt == null); modelTags.AddRange(tags); } Model.PropertyChanged += OnModelPropertyChanged; IsLoading = false; }
public void Update(TimeEntryGroup entryGroup) { for (int i = 0; i < dataObjects.Count; i++) { if (dataObjects[i].Data.Matches(entryGroup.Data)) { dataObjects [i] = entryGroup; } } }
public async static Task <IList <TimeEntryData> > GetIntentTimeEntryData(Android.Content.Intent intent) { var guids = intent.GetStringArrayListExtra(ExtraGroupedTimeEntriesGuids); if (guids == null || guids.Count == 0) { return(new List <TimeEntryData> ()); } var timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(guids); return(timeEntryList); }
public async static Task <IList <TimeEntryData> > GetIntentTimeEntryData(Android.Content.Intent intent) { var extras = intent.Extras; if (extras == null) { return(new List <TimeEntryData> ()); } // Get TimeEntryData from intent. var extraGuids = extras.GetStringArrayList(ExtraTimeEntriesIds); var timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(extraGuids); return(timeEntryList); }
public override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (viewModel == null) { var timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(TimeEntryIds); viewModel = new CreateTagViewModel(WorkspaceId, timeEntryList); } viewModel.OnIsLoadingChanged += OnModelLoaded; viewModel.Init(); ValidateTagName(); }
private async Task RemoveItemPermanentlyAsync(TimeEntryHolder holder) { if (holder == null) { return; } if (holder.TimeEntryDataList.Count > 1) { var timeEntryGroup = new TimeEntryGroup(holder.TimeEntryDataList); await timeEntryGroup.DeleteAsync(); } else { await TimeEntryModel.DeleteTimeEntryDataAsync(holder.TimeEntryDataList.First()); } }
private int GetEntryGroupIndex(TimeEntryGroup entryGroup) { int count = 0; foreach (var grp in dateGroups) { count++; // Iterate by entry list. foreach (var obj in grp.TimeEntryGroupList) { if (entryGroup.Data.Matches(obj.Data)) { return(count); } count++; } } return(-1); }
public async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (viewModel == null) { var timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(TimeEntryIds); viewModel = new TagListViewModel(WorkspaceId, timeEntryList); } viewModel.OnIsLoadingChanged += OnModelLoaded; viewModel.Init(); if (viewModel.Model.Workspace == null || viewModel.Model.Workspace.Id == Guid.Empty) { Dismiss(); } }
private TimeEntryGroup GetSuitableEntryGroupFor(DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup) { isNewEntryGroup = false; foreach (var grp in dateGroup.TimeEntryGroupList) { if (grp.CanContain(dataObject)) { return(grp); } } var entryGroup = new TimeEntryGroup(dataObject); dateGroup.Add(entryGroup); isNewEntryGroup = true; return(entryGroup); }
private TimeEntryGroup GetExistingEntryGroupFor(DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup) { isNewEntryGroup = false; foreach (var grp in dateGroup.TimeEntryGroupList) { TimeEntryData entryData; if (grp.Contains(dataObject, out entryData)) { return(grp); } } var entryGroup = new TimeEntryGroup(dataObject); dateGroup.Add(entryGroup); isNewEntryGroup = true; return(entryGroup); }
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); }
public async Task SaveProjectModel() { // Save new project. await model.SaveAsync(); // Create an extra model for Project / User relationship var userData = ServiceContainer.Resolve <AuthManager> ().User; var userId = userData != null ? userData.Id : (Guid?)null; if (userId.HasValue) { var projectUserModel = new ProjectUserModel(); projectUserModel.Project = model; projectUserModel.User = new UserModel(userId.Value); await projectUserModel.SaveAsync(); } // Update entry list. var timeEntryGroup = new TimeEntryGroup(timeEntryList); timeEntryGroup.Project = model; timeEntryGroup.Workspace = workspaceModel; await timeEntryGroup.SaveAsync(); }
public void Remove(TimeEntryGroup entryGroup) { entryGroup.Dispose(); dataObjects.Remove(entryGroup); }
public void Add(TimeEntryGroup entryGroup) { dataObjects.Add(entryGroup); }
public GroupedEditAdapter(TimeEntryGroup entryGroup) { this.entryGroup = entryGroup; }
private bool FindExistingEntry(TimeEntryData dataObject, out DateGroup dateGroup, out TimeEntryGroup existingGroup, out TimeEntryData existingEntry) { foreach (var grp in dateGroups) { foreach (var obj in grp.TimeEntryGroupList) { TimeEntryData entry; if (obj.Contains(dataObject, out entry)) { dateGroup = grp; existingGroup = obj; existingEntry = entry; return(true); } } } existingEntry = null; dateGroup = null; existingGroup = null; return(false); }