public async void OnTappedTasks(object sender, EventArgs e) { // if (itemsCount == 0) return; // Do stuff if (viewModel.IsExpandedList) { viewModel.IsExpandedList = false; viewModel.ShowHideIcon = "Arrow_right.png"; return; } //get Tasks List <ProjectInsight.Models.Tasks.Task> tasks = await TasksService.GetByProject(relatedId); viewModel.Items = new ObservableCollection <ProjectInsight.Models.Tasks.Task>(tasks); viewModel.TasksLabel = "All Tasks (" + viewModel.Items.Count + ")"; viewModel.ShowHideIcon = "Arrow_down.png"; viewModel.VisibleLoad = true; viewModel.IsExpandedList = true; var tasksCount = tasks.GroupBy(x => x.WorkPercentCompleteType.Name) .Select(x => new { Status = x.Key, Count = x.Distinct().Count() }); viewModel.Data = new ObservableCollection <TasksChartViewModel.TaskChartItem>(); foreach (var item in tasksCount) { viewModel.Data.Add(new TasksChartViewModel.TaskChartItem { Name = item.Status, Height = item.Count }); } btnViewAllTasks.IsVisible = false; if (tasks == null || tasks.Count == 0) { Chart.IsVisible = false; } else { Chart.IsVisible = true; if (hasEditPermissions) { btnViewAllTasks.IsVisible = true; } } viewModel.VisibleLoad = false; }
async Task ExecuteLoadItemsCommand(Guid?parentId) { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); CurrentItems.Clear(); //BehindItems.Clear(); //FutureItems.Clear(); //CompletedItems.Clear(); List <ProjectInsight.Models.Tasks.Task> items = await TasksService.GetByProject(parentId.Value); if (items != null) { int total = items.Count(); int brojace = 0; foreach (var item in items) { brojace++; TaskListItem newItem = new TaskListItem(); newItem.Id = item.Id.Value; newItem.Title = item.Name; bool endDateIsPast = false; //string displayDate = string.Empty; string startDate = string.Empty; string endDate = string.Empty; if (item.StartDateTimeUserLocal.HasValue && item.EndDateTimeUserLocal.HasValue) { if (item.StartDateTimeUserLocal.Value.Date == item.EndDateTimeUserLocal.Value.Date) { startDate = string.Empty; endDate = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy"); } else { startDate = item.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - "; endDate = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy"); } if (item.EndDateTimeUserLocal.Value.Date < DateTime.Now.Date) { endDateIsPast = true; } } else { if (item.StartDateTimeUserLocal.HasValue) { //displayDate = task.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - "; startDate = item.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - "; } if (item.EndDateTimeUserLocal.HasValue) { //displayDate += task.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy"); endDate = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy"); if (item.EndDateTimeUserLocal.Value.Date < DateTime.Now.Date) { endDateIsPast = true; } } } //newItem.Line2a = displayDate; newItem.Line2s = startDate; newItem.Line2e = endDate; newItem.Line2Color = endDateIsPast ? ConvertColorToHex((Color)Application.Current.Resources["RedTextColor"]) : ConvertColorToHex((Color)Application.Current.Resources["BlackTextColor"]); string workStatus = item.WorkPercentCompleteType != null ? item.WorkPercentCompleteType.Name : string.Empty; string TaskOwner = string.Empty; ///TODO to be removed this, TaskOwner should be used if (item.TaskOwner != null) { TaskOwner = item.TaskOwner.FirstName + " " + item.TaskOwner.LastName; } //else //{ // if (item.TaskOwner_Id.HasValue) // { // User taskOwner = await UsersService.GetUser(item.TaskOwner_Id.Value); // if (taskOwner != null) // TaskOwner = taskOwner.FirstName + " " + taskOwner.LastName; // } //} newItem.Line3 = (workStatus != string.Empty ? workStatus + " - " : "") + TaskOwner; newItem.Icon = "item_task.png"; newItem.ProjectId = item.Project_Id != null ? item.Project_Id.Value : Guid.Empty; int stat = 1; if (brojace <= total / 4) { stat = 1; } else if (brojace <= total / 2) { stat = 2; } else if (brojace <= 3 * total / 4) { stat = 3; } else { stat = 4; } if (parentId == new Guid("d8ed1090-69b6-45b1-9c36-04fb26e64e7a")) { newItem.TaskScheduleCurrentState = stat; } else { newItem.TaskScheduleCurrentState = (item.TaskScheduleCurrentState ?? 1); } Items.Add(newItem); } GroupProjectsByStatus(); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }