private async Task<ListEntryData> ConvertToListEntryData (TimeEntryData entry) { var project = await FetchProjectData (entry.ProjectId ?? Guid.Empty); var entryData = new ListEntryData(); entryData.Id = entry.Id; entryData.Description = entry.Description; entryData.Duration = GetDuration (entry.StartTime, entry.StopTime ?? DateTime.Now); entryData.Project = project.Name; entryData.HasProject = !String.IsNullOrEmpty (project.Name); entryData.ProjectColor = project.Color; entryData.State = entry.State; return entryData; }
private async Task <ListEntryData> ConvertToListEntryData(TimeEntryData entry) { var project = await FetchProjectData(entry.ProjectId ?? Guid.Empty); var entryData = new ListEntryData(); entryData.Id = entry.Id; entryData.Description = entry.Description; entryData.Duration = GetDuration(entry.StartTime, entry.StopTime ?? DateTime.Now); entryData.Project = project.Name; entryData.HasProject = !String.IsNullOrEmpty(project.Name); entryData.ProjectColor = project.Color; entryData.State = entry.State; return(entryData); }
public async void Load() { if (IsLoading) { return; } IsLoading = true; try { userData = ServiceContainer.Resolve <AuthManager> ().User; var store = ServiceContainer.Resolve <IDataStore> (); queryStartDate = Time.UtcNow - TimeSpan.FromDays(9); var recentEntries = await store.Table <TimeEntryData> () .OrderByDescending(r => r.StartTime) .Take(maxCount) .Where(r => r.DeletedAt == null && r.UserId == userData.Id && r.State != TimeEntryState.New && r.StartTime >= queryStartDate) .ToListAsync() .ConfigureAwait(false); dataObject = new List <ListEntryData> (); foreach (var entry in recentEntries) { var entryData = await ConvertToListEntryData(entry); dataObject.Add(entryData); } var runningEntry = await store.Table <TimeEntryData> () .Where(r => r.DeletedAt == null && r.UserId == userData.Id && r.State == TimeEntryState.Running) .ToListAsync() .ConfigureAwait(false); hasRunning = runningEntry.Count > 0; activeTimeEntry = hasRunning ? await ConvertToListEntryData(runningEntry[0]) : null; } finally { IsLoading = false; } }
public async void Load() { if (IsLoading) { return; } IsLoading = true; try { userData = ServiceContainer.Resolve<AuthManager> ().User; var store = ServiceContainer.Resolve<IDataStore> (); queryStartDate = Time.UtcNow - TimeSpan.FromDays (9); var recentEntries = await store.Table<TimeEntryData> () .OrderByDescending (r => r.StartTime) .Take (maxCount) .Where (r => r.DeletedAt == null && r.UserId == userData.Id && r.State != TimeEntryState.New && r.StartTime >= queryStartDate) .ToListAsync() .ConfigureAwait (false); dataObject = new List<ListEntryData> (); foreach (var entry in recentEntries) { var entryData = await ConvertToListEntryData (entry); dataObject.Add (entryData); } var runningEntry = await store.Table<TimeEntryData> () .Where (r => r.DeletedAt == null && r.UserId == userData.Id && r.State == TimeEntryState.Running) .ToListAsync() .ConfigureAwait (false); hasRunning = runningEntry.Count > 0; activeTimeEntry = hasRunning ? await ConvertToListEntryData (runningEntry[0]) : null; } finally { IsLoading = false; } }