Ejemplo n.º 1
0
        public IActionResult GetAll(long scenarioId = 0)
        {
            ScenarioSession scenarioSession = scenarioId > 0 ? _dataAccessService.GetScenarioSessions(User.Identity.Name).FirstOrDefault(s => s.ScenarioId == scenarioId) : null;

            if (scenarioSession != null)
            {
                IEnumerable <ScenarioAccount> scenarioAccounts = _dataAccessService.GetScenarioAccounts(scenarioSession.ScenarioSessionId);
                var identityProviders = _accountsService.GetAll().Where(a => a.AccountType == AccountType.IdentityProvider && scenarioAccounts.Any(sa => sa.AccountId == a.AccountId)).Select(a => new IdentityProviderInfoDto
                {
                    Id          = a.AccountId.ToString(CultureInfo.InvariantCulture),
                    Description = a.AccountInfo,
                    Target      = a.PublicSpendKey.ToHexString()
                });

                return(Ok(identityProviders));
            }
            else
            {
                var identityProviders = _accountsService.GetAll().Where(a => !a.IsPrivate && a.AccountType == AccountType.IdentityProvider).Select(a => new IdentityProviderInfoDto
                {
                    Id          = a.AccountId.ToString(CultureInfo.InvariantCulture),
                    Description = a.AccountInfo,
                    Target      = a.PublicSpendKey.ToHexString()
                });

                return(Ok(identityProviders));
            }
        }
Ejemplo n.º 2
0
        public IActionResult GetAll(long scenarioId = 0, bool withPrivate = false, int ofTypeOnly = 0)
        {
            ScenarioSession scenarioSession = scenarioId > 0 ? _dataAccessService.GetScenarioSessions(User.Identity.Name).FirstOrDefault(s => s.ScenarioId == scenarioId) : null;

            if (scenarioSession != null)
            {
                IEnumerable <ScenarioAccount> scenarioAccounts = _dataAccessService.GetScenarioAccounts(scenarioSession.ScenarioSessionId);

                var accounts = _accountsService.GetAll()
                               .Where(a => scenarioAccounts.Any(sa => sa.AccountId == a.AccountId))
                               .Select(a => _translatorsRepository.GetInstance <AccountDescriptor, AccountDto>().Translate(a));

                return(Ok(accounts));
            }
            else
            {
                var accounts = _accountsService.GetAll()
                               .Where(a => (withPrivate || !a.IsPrivate) && (ofTypeOnly == 0 || (int)a.AccountType == ofTypeOnly))
                               .Select(a => _translatorsRepository.GetInstance <AccountDescriptor, AccountDto>().Translate(a));

                return(Ok(accounts));
            }
        }