public IActionResult CreateTask([FromQuery] int projectId, CreateProjectTaskDto dto) { return(withUser(Request, user => { var result = _projectTaskService.CreateProjectTask(projectId, dto); if (result.ValidUser) { var assigningTaskToSelf = user.Id == dto.AssignedTo.UserId; var recipientList = assigningTaskToSelf ? new int[] { } : new int[] { dto.AssignedTo.UserId }; _reportingService.Report(new TaskAddedReport { AddedByUserId = user.Id, ProjectId = projectId, ProjectTaskId = result.Id }, recipientList); } return result.ValidUser ? new JsonResult(new { result.Id }) : ValidationProblem("Cannot assign a task on this project to a non-member"); })); }