public async Task AddProjectAsync([FromBody] ExtendedTask item) { await taskService.AddAsync(item.Task); var task = await taskService.GetAsync(el => el.Name == item.Task.Name && el.Description == item.Task.Description && el.DateStart == item.Task.DateStart && el.Status == item.Task.Status); ProjectTask tmp = await projectTaskService.GetAsync(el => item.IdUser == el.IdUser && item.IdProject == el.IdProject && task.IdTask == el.IdTask); if (tmp == null) { await projectTaskService.AddAsync(new ProjectTask { IdProject = item.IdProject, IdUser = item.IdUser, DateStart = item.Task.DateStart, IdTask = task.IdTask }); } }
public async Task <IActionResult> AddTask(MyTask task, int idProject) { if (ModelState.IsValid) { var claimsIdentity = User.Identity as ClaimsIdentity; List <Claim> claims = claimsIdentity.Claims.ToList(); var newTask = new ExtendedTask() { IdUser = int.Parse(claims[1].Value), IdProject = idProject, Task = task }; newTask.Task.DateStart = DateTime.Now; apiAccessExtendedTask.UrlAPI = "tasks/add"; await apiAccessExtendedTask.AddAsync(newTask); } return(RedirectToAction("Project", new { id = idProject })); }