public async Task <IViewComponentResult> InvokeAsync()
        {
            notifications.SortFunction = x => x.ValidFrom;
            notifications.SortOrder    = SortOrder.Descending;
            var loggedInUser = await userManager.GetUserAsync(HttpContext.User);

            if (loggedInUser == null)
            {
                return(View());
            }
            var bankAccounts = await accounts.LoadAccountsForUser(loggedInUser.Id);

            var           bankAccountsViewsList = new AccountsViewsList(bankAccounts);
            List <string> bankAccountIds        = new List <string>();

            foreach (var account in bankAccountsViewsList)
            {
                bankAccountIds.Add(account.ID);
            }
            var notificationsList =
                await notifications.LoadNotificationsForAllUsers(bankAccountIds);

            var notificationsViewsList = new NotificationViewsList(notificationsList);

            foreach (var notification in notificationsViewsList)
            {
                await loadSenderAndReceiver(notification);

                if (notification.IsSeen == false)
                {
                    NotSeenCount++;
                }
            }
            return(View(notificationsViewsList));
        }
        public async Task <IActionResult> Index(string sortOrder    = null, string currentFilter = null,
                                                string searchString = null, int?page             = null)
        {
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["SortValidFrom"] = string.IsNullOrEmpty(sortOrder) ? "validFrom_desc" : "";
            ViewData["SortType"]      = sortOrder == "type" ? "type_desc" : "type";
            ViewData["SortPayment"]   = sortOrder == "payment" ? "payment_desc" : "payment";
            ViewData["SortAccountId"] = sortOrder == "accountId" ? "accountId_desc" : "accountId";
            ViewData["SortValidTo"]   = string.IsNullOrEmpty(sortOrder) ? "validTo_desc" : "";
            ViewData["SortStatus"]    = sortOrder == "status" ? "status_desc" : "status";
            insurances.SortOrder      = sortOrder != null && sortOrder.EndsWith("_desc")
                ? SortOrder.Descending
                : SortOrder.Ascending;
            insurances.SortFunction = getSortFunction(sortOrder);
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            insurances.SearchString   = searchString;
            insurances.PageIndex      = page ?? 1;

            var loggedInUser = await userManager.GetUserAsync(HttpContext.User);

            if (loggedInUser == null)
            {
                return(View());
            }
            var bankAccounts = await accounts.LoadAccountsForUser(loggedInUser.Id);

            var           bankAccountsViewsList = new AccountsViewsList(bankAccounts);
            List <string> bankAccountIds        = new List <string>();

            foreach (var account in bankAccountsViewsList)
            {
                bankAccountIds.Add(account.ID);
            }
            var insuranceList =
                await insurances.LoadInsurancesForUser(bankAccountIds);

            var insurancesViewsList = new InsuranceViewsList(insuranceList);

            await checkForInsuranceExpire(insurancesViewsList);

            return(View(insurancesViewsList));
        }
Example #3
0
        public async Task <IActionResult> Index()
        {
            var loggedInUser = await userManager.GetUserAsync(HttpContext.User);

            if (loggedInUser == null)
            {
                return(View());
            }
            var bankAccounts = await accounts.LoadAccountsForUser(loggedInUser.Id);

            var bankAccountsViewsList = new AccountsViewsList(bankAccounts);

            await checkForAccountExpire(bankAccountsViewsList);

            return(View(bankAccountsViewsList));
        }
        private async Task <PaginatedList <INotification> > loadNotifications(ApplicationUser loggedInUser)
        {
            var bankAccounts = await accounts.LoadAccountsForUser(loggedInUser.Id);

            var           bankAccountsViewsList = new AccountsViewsList(bankAccounts);
            List <string> bankAccountIds        = new List <string>();

            foreach (var account in bankAccountsViewsList)
            {
                bankAccountIds.Add(account.ID);
            }

            var notificationsList =
                await notifications.LoadNotificationsForAllUsers(bankAccountIds);

            return(notificationsList);
        }
Example #5
0
        private async Task checkForAccountExpire(AccountsViewsList bankAccountsViewsList)
        {
            foreach (var account in bankAccountsViewsList)
            {
                var daysToExpire = (int)Math.Ceiling(((account.ValidTo ?? DateTime.MaxValue) - DateTime.Now)
                                                     .TotalDays);
                if (daysToExpire < 0)
                {
                    account.Status = Status.Inactive.ToString();
                    var acc = await accounts.GetObject(account.ID);

                    acc.Data.Status = account.Status;
                    await accounts.UpdateObject(acc);

                    continue;
                }
                if (daysToExpire < 30 && account.Status == "Active")
                {
                    account.Status = $"Active (expires in {daysToExpire} days)";
                }
            }
        }