コード例 #1
0
        public async Task <TaskDto> UpdateTask(TaskRequestDTO taskToUpdateDTO)
        {
            var taskUpdate   = _mapper.Map <Models.Task>(taskToUpdateDTO);
            var taskUpdateDB = await _taskRepository.UpdateTask(taskUpdate);

            if (taskToUpdateDTO.IsAddNewAssignee && taskToUpdateDTO.AssignedUsersToAdd.Count > 0)
            {
                foreach (var user in taskToUpdateDTO.AssignedUsersToAdd)
                {
                    var newTaskAssign = new TaskAssigning
                    {
                        Task = taskToUpdateDTO.IdTask,
                        User = user
                    };
                    await _taskRepository.CreateNewTaskAssigning(newTaskAssign);
                }
            }

            if (taskToUpdateDTO.IsRemoveAssignee && taskToUpdateDTO.AssignedUsersToRemove.Count > 0)
            {
                foreach (var user in taskToUpdateDTO.AssignedUsersToRemove)
                {
                    var taskAssigningToRemove =
                        await _taskRepository.GetTaskAssigningByTaskAndUser(taskToUpdateDTO.IdTask, user);

                    await _taskRepository.DeleteTaskAssigning(taskAssigningToRemove.IdAssign);
                }
            }
            return(await this.GetTaskById(taskToUpdateDTO.IdTask));
        }
コード例 #2
0
        public async Task <IActionResult> CreateNewTask(TaskRequestDTO newTask)
        {
            try
            {
                var newTaskDto = await _taskService.CreateNewTask(newTask);

                return(StatusCode(201, newTaskDto));
            }
            catch (HttpResponseException ex)
            {
                return(StatusCode(500, ex.Value));
            }
        }
コード例 #3
0
        public async Task <TaskDto> CreateNewTask(TaskRequestDTO newTaskRequestDto)
        {
            var newTask        = _mapper.Map <Models.Task>(newTaskRequestDto);
            var newCreatedTask = await _taskRepository.CreateNewTask(newTask);

            if (newTaskRequestDto.AssignedUsers.Count > 0)
            {
                foreach (var user in newTaskRequestDto.AssignedUsers)
                {
                    var newTaskAssign = new TaskAssigning
                    {
                        Task = newCreatedTask.IdTask,
                        User = user
                    };
                    await _taskRepository.CreateNewTaskAssigning(newTaskAssign);
                }
            }
            var newCreatedTaskDto = await this.GetTaskById(newCreatedTask.IdTask);

            return(newCreatedTaskDto);
        }
コード例 #4
0
        public async Task <IActionResult> UpdateTask(TaskRequestDTO taskToUpdate)
        {
            var updatedTask = await _taskService.UpdateTask(taskToUpdate);

            return(StatusCode(200, updatedTask));
        }