public async Task <IActionResult> GetAccountManagerList([FromRoute] Guid organizationId,
                                                                [FromQuery] AccountManagerFilters filters)
        {
            var result = await _accountManagerService
                         .GetForOrganization <AccountManagerOrganizationAccountManagerOutput>(_accountManager.OrganizationId, filters);

            return(Ok(result));
        }
Пример #2
0
        public async Task <AccountManagerTimeMatrixComposedOutput> GetComposedOutput(IOrganizationAccountManager am, TimeMatrixFilters filters)
        {
            filters.AccountManagerId       = am.AccountManagerId;
            filters.ProviderOrganizationId = am.OrganizationId;

            var matrix = await _context.TimeMatrix.ApplyWhereFilters(filters)
                         .ProjectTo <AccountManagerTimeMatrixOutput>(_mapperConfiguration)
                         .ToListAsync();

            var uniqueProjectIds        = matrix.Select(x => x.ProjectId).Distinct().ToArray();
            var uniqueContractIds       = matrix.Select(x => x.ContractId).Distinct().ToArray();
            var uniqueContractorIds     = matrix.Select(x => x.ContractorId).Distinct().ToArray();
            var uniqueAccountManagerIds = matrix.Select(x => x.AccountManagerId).Distinct().ToArray();
            var uniqueProjectManagerIds = matrix.Select(x => x.MarketerId).Distinct().ToArray();
            var uniqueCustomerIds       = matrix.Select(x => x.CustomerId).Distinct().ToArray();
            var uniqueStoryIds          = matrix
                                          .Where(x => x.StoryId != null).Select(x => x.StoryId).Distinct().ToArray();

            var projectTask     = _projectService.GetProjects <AccountManagerProjectOutput>(am, uniqueProjectIds);
            var contractsTask   = _contractService.GetContracts <AccountManagerContractOutput>(am, uniqueContractIds);
            var accountManagers =
                _accountManagerService.GetForOrganization <AccountManagerOrganizationAccountManagerOutput>(
                    am.OrganizationId, uniqueAccountManagerIds);
            var contractors =
                _contractorService.GetForOrganization <AccountManagerOrganizationContractorOutput>(am.OrganizationId,
                                                                                                   uniqueContractorIds);
            var projectManagers =
                _projectManagerService.GetForOrganization <AccountManagerOrganizationProjectManagerOutput>(
                    am.OrganizationId, uniqueProjectManagerIds);
            var customers =
                _customerService.GetForOrganization <AccountManagerOrganizationCustomerOutput>(am.OrganizationId,
                                                                                               uniqueCustomerIds);

            var stories = _storyService.GetStories <AccountManagerStoryOutput>(am, uniqueStoryIds);

            Task.WaitAll(projectTask, contractsTask, accountManagers, contractors, projectManagers, customers);

            return(new AccountManagerTimeMatrixComposedOutput
            {
                Matrix = matrix,
                Projects = projectTask.Result,
                Contracts = contractsTask.Result,
                Contractors = contractors.Result,
                ProjectManagers = projectManagers.Result,
                Customers = customers.Result,
                Stories = stories.Result
            });
        }