public async Task CreateTaskInProject(CreateTaskDtoRoot input) { var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {input.Token}"); var data = JsonConvert.SerializeObject(input.task); var stringContent = new StringContent(data); var response = await httpClient.PostAsync("https://app.asana.com/api/1.0/tasks", stringContent); if (response.StatusCode == HttpStatusCode.BadRequest) { throw new UserFriendlyException("an error occurred"); } //var responseString = await response.Content.ReadAsStringAsync(); }
private async Task CreateTasksForAsana(CreateProjectDto input) { var query = _projectRepository.GetAll(); var devOpsWorkItemsInput = new GetWorkItemsInput() { Organization = input.DevOpsOrganization, Project = input.DevOpsProject, Token = input.DevOpsAccessToken, Version = "6.0" }; var devOpsTasks = await _devOpsAppService.GetProjectWorkItems(devOpsWorkItemsInput); //devOpsTasks = devOpsTasks.Where(a => !query.Any(x => x.TaskTitle == a.fields.SystemTitle)).ToList(); var asanaCreateTaskDtoRoot = new CreateTaskDtoRoot() { Token = input.AsanaToken, }; asanaCreateTaskDtoRoot.task = new CreateTaskDto(); var asanaTasks = new CreateTaskDtoInput(); var project = new ProjectDto(); foreach (var a in devOpsTasks) { //project.Type = "Asana"; //project.ProjectTitle = input.AsanaProjectName; //project.TaskTitle = //project.TasksDescription = //project.Workspace = asanaTasks.name = a.fields.SystemTitle; //asanaTasks.notes = StripHTML(a.fields.SystemDescription); asanaTasks.workspace = input.AsanaWorkSpace; asanaTasks.projects = new List <string>() { input.AsanaProjectId }; asanaCreateTaskDtoRoot.task.data = asanaTasks; //await SaveProjectInDb(project); await _asanaAppService.CreateTaskInProject(asanaCreateTaskDtoRoot); } }
public async Task CreateTaskInProject(CreateTaskDtoRoot input) { await _asanaManager.CreateTaskInProject(input); }