예제 #1
0
        public async Task <RemindersVM> GetNotifications()
        {
            await incomeService.MissedIncomeEntriesAsync();

            //await spendingService.MissedCreditCardInterestEntriesAsync();
            //await cnwService.MissedCNWPaymentEntriesAsync();

            var finances         = (await GetFinances(resyncNextDueDates: false)).Where(x => x.PaymentStatus != PaymentStatus.Ended);
            var upcomingPayments = upcomingPaymentRemindersAsync(finances);
            var getReminders     = await remindersService.GetAllAsync();

            if (getReminders.Any())
            {
                foreach (var reminder in getReminders)
                {
                    reminder.DaysUntilDue = CalculateDays(reminder.DueDate, DateTime.UtcNow);
                }
            }

            var reminders = getReminders
                            .Concat(upcomingPayments)
                            .Where(x => x.Display == true)
                            .OrderBy(x => x.Sort)
                            .ThenBy(x => x.DueDate)
                            .ThenByDescending(x => x._priority);

            return(new RemindersVM
            {
                OverDueReminders = reminders.Where(x => x.PaymentStatus == PaymentStatus.Late),
                DueTodayReminders = reminders.Where(x => x.PaymentStatus == PaymentStatus.DueToday),
                UpcomingReminders = reminders.Where(x => x.PaymentStatus == PaymentStatus.Upcoming),
                Alerts = reminders.Where(x => x.PaymentStatus == PaymentStatus.Unknown)
            });
        }
예제 #2
0
        public async Task <HttpResponseMessage> GetRemindersAsync()
        {
            var reminders = await remindersService.GetAllAsync();

            return(Request.CreateResponse(HttpStatusCode.OK, new { Reminders = reminders }));
        }