// GET: /NewsFeed?index=0&number=5 public async Task <IEnumerable <NoticeViewModel> > Get(int index, int number) { var user = await User.Identity.GetApplicationUserAsync(); var notices = await nm.GetNewsFeedAsync(user.Id, index, number); List <NoticeViewModel> vm = new List <NoticeViewModel>(); foreach (var i in notices) { vm.Add(NoticeViewModel.From(i)); } return(vm); }
// GET: /GetFeed?index=6&number=5 public async Task <ActionResult> GetFeed(int?index, int?number) { int i = index ?? 0; int n = number ?? 5; NoticeManager nm = new NoticeManager(); var user = await User.Identity.GetApplicationUserAsync(); var notices = await nm.GetNewsFeedAsync(user.Id, i, n); List <DetailedNoticeViewModel> vms = new List <DetailedNoticeViewModel>(); foreach (var notice in notices) { vms.Add(NoticeMappings.To <DetailedNoticeViewModel>(notice)); } return(View(vms)); }
public async Task <ActionResult> Index() { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "About")); } NoticeManager nm = new NoticeManager(); var user = await User.Identity.GetApplicationUserAsync(); var notices = await nm.GetNewsFeedAsync(user.Id, 0, 6); List <DetailedNoticeViewModel> vms = new List <DetailedNoticeViewModel>(); foreach (var n in notices) { vms.Add(await NoticeMappings.ToDetailedNoticeViewModelAsync(n)); } return(View(vms)); }