public static void Map(AsanaTask task, long projectId, long workspaceId) { if (task.assignee != null) { task.assigneeid = task.assignee.id; } task.projectid = projectId; task.workspaceid = workspaceId; task.IsPriorityHeading = task.name.EndsWith(":"); if (task.parent != null) { task.parentId = task.parent.id; } if (task.followers != null) { task.SetFollowers(task.followers.Select(x => x.id).ToList()); } }
async System.Threading.Tasks.Task ProcessFollowers(AsanaTask task) { var currentFollowers = SelectedFollowers.Select(x => x.id).ToList(); var followersToAdd = new List <long>(); var followersToRemove = new List <long>(); foreach (var currentFollower in currentFollowers) { if (!OldFollowersIds.Contains(currentFollower)) { followersToAdd.Add(currentFollower); } } foreach (var oldFollowersId in OldFollowersIds) { if (!currentFollowers.Contains(oldFollowersId)) { followersToRemove.Add(oldFollowersId); } } var success = false; if (followersToAdd.Any()) { var response = await new AsanaRespository().AddFollowers(task.id, followersToAdd); if (AsanaClient.ProcessResponse(response, true)) { success = true; } else { return; } } if (followersToRemove.Any()) { var response = await new AsanaRespository().RemoveFollowers(task.id, followersToRemove); if (AsanaClient.ProcessResponse(response, true)) { success = true; } else { return; } } if (success) { task.SetFollowers(currentFollowers); } task.followers = null; if (followersToAdd.Any() || followersToRemove.Any()) { await PrepareAndSaveTaskToDb(task); } }