コード例 #1
0
        public async Task <ActionResult> Index(string id = "Hot", int page = 0)
        {
            ViewBag.id   = id;
            ViewBag.page = page;
            var memeList = await _memeRepository.GetShortMemesAsync(id);

            ShortMemesListViewModel list = null;

            if (page * 9 + 9 > memeList.Count)
            {
                list = new ShortMemesListViewModel
                {
                    Memes           = memeList.GetRange(page * 9, memeList.Count - page * 9),
                    CategoriesNames = _categoriesRepository.GetAllCategoriesNames()
                };
            }
            list = new ShortMemesListViewModel
            {
                Memes           = memeList.GetRange(page * 9, 9),
                CategoriesNames = _categoriesRepository.GetAllCategoriesNames()
            };
            if (Request.IsAuthenticated)
            {
                var identity = (ClaimsIdentity)User.Identity;
                var name     = identity.GetUserName();
                var user     = _gagDb.Users.First(u => u.Name == name);
                list.SetLikedMemes(user);
            }
            return(View(list));
        }
コード例 #2
0
ファイル: MemeController.cs プロジェクト: JakNat/FakeGag
        public async Task <ActionResult> MemeDetail(int id = 1)
        {
            var meme = await _memeRepository.GetDetailedMemeAsync(id);

            meme.CategoriesNames = _categoriesRepository.GetAllCategoriesNames();
            return(View(meme));
        }