コード例 #1
0
        public ActionResult Index()
        {
            var vModel = new HomeViewModel();

            vModel.Channels = new PVMChannels()
            {
                Channels = cRepo.Get(), CurrentChannel = cRepo.Get()[0].Id
            };
            vModel.TopUsers = uRepo.GetTop();
            return(View(vModel));
        }
コード例 #2
0
        // GET: Post
        public ActionResult Index(int chn)
        {
            var posts = new List <Post>();

            posts = repo.Get(cRepo.Get(chn));
            posts.OrderByDescending(c => c.Date).ThenByDescending(c => c.Id).ToList();

            var channels = cRepo.Get();
            var PVMC     = new PVMChannels()
            {
                Channels = channels, CurrentChannel = chn, NewChannel = new Channel()
            };

            var top    = uRepo.GetTop();
            var extras = new Dictionary <string, int>();

            extras.Add(top[0].Username, 0);
            extras.Add(top[1].Username, 1);
            extras.Add(top[2].Username, 2);
            extras.Add(top[3].Username, 3);
            extras.Add(top[4].Username, 4);

            List <PVMExtra> PVME = new List <PVMExtra>();

            foreach (var i in posts)
            {
                if (extras.ContainsKey(i.User.Username))
                {
                    PVME.Add(new PVMExtra()
                    {
                        Post = i, PostRating = extras[i.User.Username]
                    });
                }
                else
                {
                    PVME.Add(new PVMExtra()
                    {
                        Post = i, PostRating = 10
                    });
                }
            }


            var vModel = new PostViewModel()
            {
                Posts = PVME, ChannelModel = PVMC, NewPost = new PostCreateViewModel()
                {
                    Channel = chn
                }, NewComment = new Comment()
            };

            return(View(vModel));
        }