Ejemplo n.º 1
0
        public ActionResult Trending()
        {
            ContentSharingEntities1 db = new ContentSharingEntities1();


            var model2 = db.ImgDB.ToList();


            List <ImageDBList> model = new List <ImageDBList>(model2.Count);

            for (int i = 0; i < model2.Count; i++)
            {
                ImageDBList List = new ImageDBList()
                {
                    ImgID         = model2[i].ImgID,
                    UserID        = model2[i].UserID,
                    Route         = model2[i].Route,
                    Description   = model2[i].Description,
                    CommentNumber = model2[i].Comment.Count(),
                    VoteNumber    = model2[i].ImgVote.Count
                };

                if (List.VoteNumber > 5)
                {
                    model.Add(List);
                }
            }



            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Hot()
        {
            ContentSharingEntities1 db = new ContentSharingEntities1();


            var model2 = db.ImgDB.ToList();


            List <ImageDBList> model = new List <ImageDBList>(model2.Count);

            for (int i = 0; i < model2.Count; i++)
            {
                ImageDBList List = new ImageDBList()
                {
                    ImgID         = model2[i].ImgID,
                    UserID        = model2[i].UserID,
                    Route         = model2[i].Route,
                    Description   = model2[i].Description,
                    CommentNumber = model2[i].Comment.Count(),
                    VoteNumber    = model2[i].ImgVote.Count
                };

                if (List.VoteNumber > 7)
                {
                    model.Add(List);
                }
            }



            return(View(model));



            //var model2 = (from I in db.ImgDB
            //              join C in db.Comment
            //              on I.ImgID equals C.ImageID
            //              into groupofleft
            //              group I by I.ImgID into grup
            //              select new
            //              {
            //                  ImgID = grup.Key,
            //                  Count = grup.Count()
            //              }).ToList();


            //var model3 = (from I in db.ImgDB
            //              join C in db.Comment on I.ImgID equals C.ImageID into j1
            //              from j2 in j1.DefaultIfEmpty()
            //              group j2 by
            //              new
            //              {
            //                  I.ImgID,
            //                  I.Route,
            //                  I.UserID,
            //                  I.Description
            //              }
            //              into grouped
            //              select new
            //              {
            //                  ParentId = grouped.Key,
            //                  Count = grouped.Count(x => x.ImageID != null)


            //              }).ToList();

            //var model4 = (from C in db.Comment
            //              join I in db.ImgDB on C.ImageID equals I.ImgID into j1
            //              from j2 in j1.DefaultIfEmpty()
            //              group j2 by C.ImageID into grouped
            //              select new
            //              {

            //                  ParentId = grouped.Key,
            //                  Route = grouped.Select(x=> x.Route),
            //                  Count = grouped.Count(x => x.ImgID != null)


            //              }).ToList();


            //var model = from I in db.ImgDB group I by I.ImgID;

            //var model = sql("Select ImgDB.ImgID,ImgDB.ImgVote,ImgDB.Route,ImgDB.UserID,ImgDB.Description,Count(Comment.ImageID) as Sum_Comment from ImgDB left JOIN Comment on(ImgDB.ImgID = Comment.ImageID) group by ImgDB.ImgID,ImgDB.ImgVote,ImgDB.Route,ImgDB.UserID,ImgDB.Description").ToList();
        }