Esempio n. 1
0
        public ActionResult Index(int id = 1, int pageIndex = 1, int page = 1)
        {
            //var str1 = "古典吉他";
            var users = (from m in db.Users.OrderByDescending(p => p.User_addtime) select m).Take(6);

            var       score1   = (from m in db.MusicScore.Where(p => p.Ms_label == "古典吉他").OrderByDescending(p => p.Ms_addtime) select m).Take(10);
            var       score2   = (from m in db.MusicScore.Where(p => p.Ms_label == "民谣吉他").OrderByDescending(p => p.Ms_addtime) select m).Take(10);
            var       score3   = (from m in db.MusicScore.Where(p => p.Ms_label == "电吉他").OrderByDescending(p => p.Ms_addtime) select m).Take(10);
            var       score4   = (from m in db.MusicScore.Where(p => p.Ms_label == "尤克里里").OrderByDescending(p => p.Ms_addtime) select m).Take(10);
            var       score5   = (from m in db.MusicScore.Where(p => p.Ms_label == "其他").OrderByDescending(p => p.Ms_addtime) select m).Take(10);
            var       score6   = (from m in db.MusicScore.OrderByDescending(p => p.ReadCount) select m);
            const int pageSize = 20;

            if (Request.IsAjaxRequest())
            {
                var target = Request.QueryString["target"];
                if (target == "mscore")
                {
                    return(PartialView("_Index1", score6.ToPagedList(id, pageSize)));
                }
            }

            var index = new Guitar.ViewModel.MusicDetailsViewModel()
            {
                MScore1 = score1,
                MScore2 = score2,
                MScore3 = score3,
                MScore4 = score4,
                MScore5 = score5,
                MScore6 = score6.ToPagedList(page, pageSize),
                Us2     = users,
            };

            return(View(index));
        }
Esempio n. 2
0
        public ActionResult Display(int?id, int md = 1, int pageIndex = 1, int page = 1)
        {
            //const int pageSize = 5;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TempData["Ms_idd"] = id;
            ViewBag.Msid       = id;
            TempData["Ms_id2"] = id;
            MusicScore ms = db.MusicScore.Find(id);
            //MusicScoreStatistics msta = db.MusicScoreStatistics.Find(id);
            var   usid = (from m in db.MusicScore.Where(p => p.Ms_id == id) select m.User_id).FirstOrDefault();
            Users us   = db.Users.Find(usid);

            //MusicScoreStatistics msta = db.MusicScoreStatistics.Find(id);

            if (ms == null && us == null)
            {
                return(HttpNotFound());
            }

            //var us=from m in db.Users.Where(p=>p.User_id==usid) select m;
            var ms1     = (from m in db.MusicScore.Where(p => p.User_id == usid).OrderByDescending(p => p.Ms_addtime) select m).Take(5);
            var msc     = from m in db.MusicScoreComment.Where(p => p.Ms_id == id).OrderByDescending(p => p.Addtime) select m;
            var comment = from m in db.MusicScoreComment
                          join n in db.Users on m.User_id equals n.User_id
                          select new MusicScoreCommentViewModel
            {
                Ms_commentid = m.Ms_commentid,
                Ms_id        = m.Ms_id,
                content      = m.content,
                Addtime      = m.Addtime,
                User_id      = n.User_id,
                User_name    = n.User_name,
                User_img     = n.User_img,
            };
            //var comment1 = .ToPagedList(idd, pageSize);
            var msr = (from n in db.MusicScoreReply
                       join m in msc on n.Ms_commentid equals m.Ms_commentid
                       join q in db.Users on n.User_id equals q.User_id
                       select new MusicCommentReplyViewModel
            {
                Ms_replyid = n.Ms_replyid,
                Ms_commentid = m.Ms_commentid,
                content = n.content,
                Addtime = n.Addtime,
                Ms_id = m.Ms_id,
                User_id = n.User_id,
                User_name = q.User_name,
                User_img = q.User_img
            });
            int commentid = Convert.ToInt32(Request["Commentid1"]);
            var msrr      = from m in db.MusicScoreReply.Where(p => p.Ms_commentid == commentid).OrderByDescending(p => p.Addtime) select m;

            var comment1 = from m in comment.Where(p => p.Ms_id == id).OrderByDescending(p => p.Addtime) select m;
            //var msta = from m in db.MusicScoreStatistics.Where(p => p.Ms_id == id) select m;
            //var msta = from m in db.MusicScoreStatistics where m.Ms_id == id select m;
            //分页数据
            const int pageSize = 5;

            if (Request.IsAjaxRequest())
            {
                var target = Request.QueryString["target"];
                if (target == "articles")
                {
                    return(PartialView("_display1", comment1.ToPagedList(md, pageSize)));
                }
            }
            var index = new Guitar.ViewModel.MusicDetailsViewModel()
            {
                Us      = us,
                MScore  = ms,
                MScore1 = ms1,
                MSC     = msc,
                MSR     = msr,
                Msr     = msrr,
                msc11   = comment1.ToPagedList(page, pageSize),
            };

            //if (Request.IsAjaxRequest())
            //    return PartialView("_PartialPage1", comment.OrderByDescending(a => a.Addtime).ToPagedList(md, 3));
            return(View(index));
        }