public async Task <System.Collections.ObjectModel.ObservableCollection <TaskSubitem> > GetUserTaskSubitemsAlreadyStarted(string userId) { if (await EnsureLogin()) { var taskService = new TaskItemService(base.AccessToken); var taskItems = await taskService.GetTaskItems(userId); var result = new List <TaskSubitem>(); foreach (var taskItem in taskItems) { var taskSubitems = await MobileService.GetTable <TaskSubitem>() .Where(t => t.TaskItemId == taskItem.Id && t.TaskStatusId != ((int)TaskStatusEnum.Completed).ToString() && t.TaskStatusId != ((int)TaskStatusEnum.Rejected).ToString()) .ToCollectionAsync(); Func <TaskSubitem, bool> func = t => t.ExecutorId == userId && t.StartDateTime.HasValue && t.StartDateTime.Value.Date <= DateTime.Today && t.StartDateTime.Value.Date > DateTime.Today.AddDays(-2); if (taskSubitems.Any(func)) { result.AddRange(taskSubitems.Where(func)); } } return(result.ToObservableCollection()); } return(null); }
public async Task <ObservableCollection <TaskSubitem> > GetCompletedTaskSubitems(string userId, DateTime fromDate, DateTime toDate) { if (await EnsureLogin()) { var taskService = new TaskItemService(base.AccessToken); var taskItems = await taskService.GetTaskItems(userId); var result = new List <TaskSubitem>(); foreach (var taskItem in taskItems) { var taskSubitems = await MobileService.GetTable <TaskSubitem>() .Where(t => t.TaskItemId == taskItem.Id && t.TaskStatusId == ((int)TaskStatusEnum.Completed).ToString()) .ToCollectionAsync(); Func <TaskSubitem, bool> func = t => t.ExecutorId == userId && t.StartDateTime.HasValue && t.StartDateTime.Value.Date >= fromDate.Date && t.EndDateTime.HasValue && t.EndDateTime.Value.Date < toDate.Date; if (taskSubitems.Any(func)) { result.AddRange(taskSubitems.Where(func)); } } return(result.ToObservableCollection()); } return(null); }
public async Task <ObservableCollection <TaskSubitemWork> > GetUserTaskSubitemWorks(string userId, DateTime fromDate, DateTime toDate) { if (await EnsureLogin()) { var taskService = new TaskItemService(base.AccessToken); var taskSubitemService = new TaskSubitemService(base.AccessToken); var taskSubitemWorksService = new TaskSubitemWorkService(base.AccessToken); var taskItems = await taskService.GetTaskItems(userId); var results = new List <TaskSubitemWork>(); foreach (var taskItem in taskItems) { var subItems = await taskSubitemService.GetTaskSubitems(taskItem.Id); //TODO foreach (var subitem in subItems) { var works = await taskSubitemWorksService.GetTaskSubitemWorks(subitem.Id); var worksBetweenDates = works.Where( w => w.StartDateTime >= fromDate && w.EndDateTime.HasValue && w.EndDateTime.Value < toDate); if (worksBetweenDates.Any()) { results.AddRange(worksBetweenDates); } } } return(results.ToObservableCollection()); } return(null); }