Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            string caseflowUserId = GetCaseflowUserId();

            List <AccountSummary> accountSummaries = await _accountsService.GetAccounts(caseflowUserId);

            List <string> lowellReferences = accountSummaries.Select(x => x.AccountReference).ToList();
            IDictionary <string, Guid> surrogateKeysByLowellReference = ApplicationSessionState.AddLowellReferenceSurrogateKeys(lowellReferences);

            Guid?  lowellFinancialAccountSurrogateKey = null;
            string loggedInLowellRef = null;

            foreach (AccountSummary account in accountSummaries)
            {
                if (!account.AccountStatusIsWithSolicitors && lowellFinancialAccountSurrogateKey == null)
                {
                    lowellFinancialAccountSurrogateKey = surrogateKeysByLowellReference[account.AccountReference];
                    loggedInLowellRef = ApplicationSessionState.GetLowellReferenceFromSurrogate(lowellFinancialAccountSurrogateKey.Value);
                }
            }

            CustomerSummary customerSummary = await _accountsService.CreateCustomerSummary(accountSummaries, loggedInLowellRef, surrogateKeysByLowellReference);

            MyAccountsVm vm = _mapper.Map <CustomerSummary, MyAccountsVm>(customerSummary);

            if (TempData != null && TempData.ContainsKey("GTMEvents"))
            {
                vm.GtmEvents = JsonConvert.DeserializeObject <List <GtmEvent> >(TempData["GTMEvents"].ToString());
                TempData.Remove("GTMEvents");
            }

            _gtmService.RaiseMyAccountsPageViewedEvent(vm, LoggedInUserId);

            await _webActivityService.LogMyAccountsPageViewed(loggedInLowellRef, LoggedInUserId);

            return(View(vm));
        }