public async Task <IViewComponentResult> InvokeAsync() { List <ReminderOverviewListItem> viewModel = await Task.Run(() => { List <ReminderOverviewListItem> vm = new List <ReminderOverviewListItem>(); List <ReminderStateType> reminderTypes = new List <ReminderStateType>() { ReminderStateType.NonExpired, ReminderStateType.Expiring, ReminderStateType.Expired }; foreach (ReminderStateType item in reminderTypes) { vm.Add(new ReminderOverviewListItem() { Quantity = service.GetRemindersByType(User.GetUserId(), new List <ReminderStateType>() { item }).Count, Type = item }); } return(vm); }); return(View(viewModel)); }
public IActionResult ListReminders(ReminderStateType?type = null) { List <Reminder> reminders = !type.HasValue ? _expirationReminderService.GetReminders(User.GetUserId()) : _expirationReminderService.GetRemindersByType(User.GetUserId(), new List <ReminderStateType>() { type.Value }); return(View(Mapper.Map <ReminderListViewModel>(reminders))); }