public async Task <IActionResult> CreateTask([Required] CreateTaskViewModel model) { var task = mapper.Map <PlatformTask>(model); var taskId = await taskCreator.CreateTask(task); return(CreatedAtAction(nameof(RetrieveTask), new { taskId }, new{ taskId })); }
public async Task <TaskCreateResponse> TaskCreate(TaskCreateRequest request) { TaskCreateResponse response; var board = await _boardRepository.GetAsync(request.BoardId); if (board == null) { response = new TaskCreateResponse { Data = null }; response.Failed(_errorService.GetError(ErrorType.ItemNotFound)); return(response); } if (board.CreatedById != request.UserId) { response = new TaskCreateResponse { Data = null }; response.Failed(_errorService.GetError(ErrorType.AccessDenied)); return(response); } if (board.Tasks == null) { board.Tasks = new List <Task>(); } var task = _taskCreator.CreateTask(request); await _boardRepository.InsertTaskAsync(request.BoardId, task); response = _taskCreator.CreateTaskCreateResponse(task); response.Succeeded(); return(response); }