/// <summary> /// Resets the assigned tasks for a user /// </summary> /// <param name="user">User</param> /// <returns>Task</returns> private async Task ResetAssignedTasks(GoNorthUser user) { List <TaskBoard> taskBoards = await _taskBoardDbAccess.GetAllTaskBoardsByAssignedUser(user.Id); foreach (TaskBoard curBoard in taskBoards) { bool changedBoard = false; foreach (TaskGroup curTaskGroup in curBoard.TaskGroups) { if (curTaskGroup.AssignedTo == user.Id) { curTaskGroup.AssignedTo = null; changedBoard = true; } foreach (GoNorthTask curTask in curTaskGroup.Tasks) { if (curTask.AssignedTo == user.Id) { curTask.AssignedTo = null; changedBoard = true; } } } if (changedBoard) { await _taskBoardDbAccess.UpdateTaskBoard(curBoard); } } }
/// <summary> /// Fills the assigned tasks of the user /// </summary> /// <param name="response">Response to send</param> /// <param name="currentUser">Current user</param> /// <returns>Task</returns> private async Task FillAssignedTasks(PersonalDataResponse response, GoNorthUser currentUser) { List <TaskBoard> taskBoards = await _taskBoardDbAccess.GetAllTaskBoardsByAssignedUser(currentUser.Id); response.AssignedTasks = taskBoards.SelectMany(t => t.TaskGroups.Where(tg => tg.AssignedTo == currentUser.Id)).Select(t => new TrimmedTask { Name = t.Name, Description = t.Description, IsTaskGroup = true }).ToList(); response.AssignedTasks.AddRange(taskBoards.SelectMany(t => t.TaskGroups.SelectMany(tg => tg.Tasks.Where(ta => ta.AssignedTo == currentUser.Id))).Select(t => new TrimmedTask { Name = t.Name, Description = t.Description, IsTaskGroup = false }).ToList()); }