示例#1
0
        public async Task <GetSubordinateTopicTreeOperationResponse> Execute(GetSpecificTeamTopicTreeOperationRequest request)
        {
            var manager = await _authorizationContext.GetEmployeeIfAuthorizedFor(request.EmployeeId);

            if (manager == null)
            {
                throw new ApplicationException($"Not authorized for '{request.EmployeeId}'");
            }

            var team = await _teamRepository.GetByManagerIdAsync(manager.Id);

            if (team == null)
            {
                throw new EmployeeDoesNotManageAnyTeamException(manager.Id);
            }

            var getPartialTreeRequest = new GetPartialSubordinateTopicTreeOperationRequest
            {
                EmployeeIds = team.Employees
                              .Select(employee => employee.Id)
                              .Concat(new [] { manager.Id })
                              .ToList()
            };

            return(await _getPartialSubordinateTopicTreeOperation.Execute(getPartialTreeRequest));
        }
        public async Task <GetSubordinateTopicTreeOperationResponse> Execute()
        {
            var employee = await _authorizationContext.CurrentEmployee();

            var request = new GetSpecificTeamTopicTreeOperationRequest
            {
                EmployeeId = employee.Id
            };

            return(await _getSpecificTeamTopicTreeOperation.Execute(request));
        }
        public async Task <IActionResult> GetTeamTopicTree([Required] Guid id)
        {
            var request = new GetSpecificTeamTopicTreeOperationRequest
            {
                EmployeeId = id
            };
            GetSubordinateTopicTreeOperationResponse response;

            try
            {
                response = await _getSpecificTeamTopicTreeOperation.Execute(request);
            }
            catch (EmployeeDoesNotManageAnyTeamException ex)
            {
                return(NotFound(new ErrorModel(ex.Message)));
            }

            return(Ok(new TeamTopicTreeModel(response)));
        }