コード例 #1
0
        public async Task <ActionResult> AccountPaymentsIn(int id, int tries = 1)
        {
            Debug.WriteLine($"App-Debug: {(nameof(AccountsController))} {nameof(AccountPaymentsIn)} {id} {tries}");
            var entityType = "Account.Payments";

            if (await _siteConnector.Challenge(_identity, $"api/challenge/required/{entityType}/{id}"))
            {
                var model = new ChallengeViewModel
                {
                    MenuType   = _menuType,
                    EntityType = entityType,
                    Identifier = $"{id}",
                    Identity   = _identity,
                    ReturnTo   = $"{_siteConnector.Services[SupportServices.Portal]}views/accounts/{id}/payments/int",
                    Tries      = tries,
                };
                MvcApplication.Challenges.Add(model.ChallengeId, model);
                return(RedirectToAction("Challenge", "Challenge", new { model.ChallengeId }));
            }

            await _siteConnector.Challenge(_identity, $"api/challenge/refresh/{entityType}/{id}");

            var paymentsView =
                await _siteConnector.DownloadView(SupportServices.Portal, _identity, $"resources/payments/accounts/{id}/in");

            var accountPaymentsViewModel = new AccountPaymentsViewModel
            {
                Account = _accountViewModels.Accounts.FirstOrDefault(x => x.AccountId == id),
                View    = paymentsView
            };

            if (NavItem.IsAResourceRequest(Request))
            {
                return(View("_accountPayments", accountPaymentsViewModel));
            }

            var identifiers = new Dictionary <string, string> {
                { "accountId", $"{id}" }
            };
            var menuNavItems = NavItem.TransformNavItems(
                MvcApplication.NavItems
                .Where(x => x.Key.StartsWith($"{_menuType}"))
                .ToDictionary(x => x.Key, x => x.Value),
                _siteConnector.Services[SupportServices.Portal],
                identifiers
                ).Select(s => s.Value).ToList();

            ViewBag.Menu = Menu.ConfigureMenu(menuNavItems, entityType,
                                              new List <string> {
                $"{entityType}", $"{entityType}.In"
            }, MenuOrientations.Horizontal);

            return(View("_accountPayments", accountPaymentsViewModel));
        }
コード例 #2
0
        public async Task <MvcHtmlString> Get(string path)
        {
            Debug.WriteLine($"App-Debug: {(nameof(ResourcesController))} {nameof(Get)} {path}");

            var source = path.Split('/').FirstOrDefault();

            if (string.IsNullOrWhiteSpace(source))
            {
                return(new MvcHtmlString(string.Empty));
            }

            var ok = Enum.TryParse(source, true, out SupportServices service);

            if (!ok)
            {
                return(await Task.Run(() => new MvcHtmlString(string.Empty)));
            }

            _siteConnector.SetCustomHeader("X-Resource", null);

            var resource = await _siteConnector.DownloadView(service, _identity, $"{path}");

            _siteConnector.ClearCustomHeaders("X-Resource");

            return(resource);
        }
コード例 #3
0
        public async Task <ActionResult> Index()
        {
            Debug.WriteLine($"App-Debug: {(nameof(ResourcesController))} {nameof(Index)} - Entry point");

            // OK.... here we go.
            // Make download calls to Users, Accounts, Accounts will ask for a Download roundtrip for Payements.. by Account
            var usersView = await _siteConnector.DownloadView(SupportServices.Users, _identity, "users");

            var accountsView = await _siteConnector.DownloadView(SupportServices.Accounts, _identity, "accounts");

            var indexViewModel = new IndexViewModel
            {
                UsersView    = usersView,
                AccountsView = accountsView
            };

            return(View("index", indexViewModel));
        }