Ejemplo n.º 1
0
        public async Task <TaskDetailsDto> Handle(AssignUserToTaskCommand request, CancellationToken cancellationToken)
        {
            var taskFromDb = await _taskService.GetTaskWithEagerLoadingAsync(request.TaskId);

            if (!_authService.UserRoleAdminOrUserIdMatches(request.UserId))
            {
                throw new AuthenticationException("You don't have permission to assign anyone else beside yourself to a task.");
            }

            await _taskService.AddUserToTaskAsync(taskFromDb, request.UserId);

            return(_mapper.Map <TaskDetailsDto>(taskFromDb));
        }