예제 #1
0
        public async Task <ActionResult> Create(int boardId, int taskId, int memberId)
        {
            bool boardExists = await _boardRepository.Exists(boardId);

            if (!boardExists)
            {
                return(V1NotFound("Board not found"));
            }

            int         userId     = int.Parse(HttpContext.User.Identity.Name);
            BoardMember userMember = await _memberRepository.GetByBoardIdAndUserId(boardId, userId);

            if (userMember is null)
            {
                return(Forbid());
            }
            KanbanTask task = await _taskRepository.GetByIdAndBoardId(taskId, boardId);

            if (task is null)
            {
                return(V1NotFound("Task not found"));
            }
            BoardMember member = await _memberRepository.GetByBoardIdAndUserId(boardId, memberId);

            if (member is null)
            {
                return(V1NotFound("Member not found"));
            }

            bool existsAssignment = await _assignmentRepository.ExistsAssignment(taskId, member);

            if (!existsAssignment)
            {
                await _assignmentRepository.Insert(taskId, member);
            }
            return(NoContent());
        }