public ActionResult UserIndex(int User_Id)
        {
            Users users = db.Users.Find(User_Id);
            var   index = new Guitar.ViewModel.UsersViewModel
            {
                Us = users,
            };

            return(View(index));
        }
Exemple #2
0
        //public UsersBll usersBll = new UsersBll();
        // GET: Users
        public ActionResult Index(int?id, int nid = 1, int pageIndex = 1, int page = 1)
        {
            //var userid = 2;
            //if (id == null)
            //{
            //    id = Convert.ToInt32(Session["Users_id"].ToString());
            //}
            var user   = db.Users.Find(id);
            var mscore = from m in db.MusicScore
                         join n in db.Users on m.User_id equals n.User_id
                         select new MusicUserViewModel
            {
                Ms_id      = m.Ms_id,
                Ms_title   = m.Ms_title,
                Ms_addtime = m.Ms_addtime,
                Ms_label   = m.Ms_label,
                Ms_img     = m.Ms_img,
                User_id    = n.User_id,
                User_name  = n.User_name,
            };
            var mscore1 = from m in mscore.Where(p => p.User_id == id).OrderByDescending(p => p.Ms_addtime) select m;
            var mscount = mscore1.Count();

            ViewBag.mscount = mscount;
            var video = from m in db.Video
                        join n in db.Users on m.User_id equals n.User_id
                        select new VideoUserViewModel
            {
                Vi_id      = m.Vi_id,
                Vi_title   = m.Vi_title,
                Vi_addtime = m.Vi_addtime,
                Vi_label   = m.Vi_label,
                Vi_img     = m.Vi_img,
                User_id    = n.User_id,
                User_name  = n.User_name,
            };
            var video1  = from m in video.Where(p => p.User_id == id).OrderByDescending(p => p.Vi_addtime) select m;
            var vicount = video1.Count();

            ViewBag.vicount = vicount;
            var post = from m in db.Post
                       join n in db.Users on m.User_id equals n.User_id
                       select new PostUserViewModel
            {
                Po_id      = m.Po_id,
                Po_title   = m.Po_title,
                Po_addtime = m.Po_addtime,
                Po_label   = m.Po_label,
                Po_img     = m.Po_img,
                User_id    = n.User_id,
                User_name  = n.User_name,
            };
            var post1   = from m in post.Where(p => p.User_id == id).OrderByDescending(p => p.Po_addtime) select m;
            var pocount = post1.Count();

            ViewBag.pocount = pocount;
            const int pageSize = 6;

            if (Request.IsAjaxRequest())
            {
                var target = Request.QueryString["target"];
                if (target == "articles")
                {
                    return(PartialView("_AjaxArticles1",
                                       mscore1.ToPagedList(nid, pageSize)));
                }
                if (target == "articles2")
                {
                    return(PartialView("_AjaxArticles2",
                                       video1.ToPagedList(pageIndex, pageSize)));
                }
                return(PartialView("_AjaxArticles3",
                                   post1.ToPagedList(page, pageSize)));
            }
            var index = new Guitar.ViewModel.UsersViewModel()
            {
                Us = user,
                MS = mscore1.ToPagedList(nid, pageSize),
                VO = video1.ToPagedList(pageIndex, pageSize),
                PO = post1.ToPagedList(page, pageSize),
            };

            return(View(index));
        }