Ejemplo n.º 1
0
        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 }));
        }
Ejemplo n.º 2
0
        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);
        }