Ejemplo n.º 1
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            RoteValueHelper rvh = new RoteValueHelper();
            var index = rvh.GetInt("index", 1);

            var pageSize = 10;
            var startIndex = (index - 1) * pageSize;
            var pageBll = new BLL.Page();

            var pages = pageBll.GetPages(startIndex, 10);
            List<Photo.Web.Models.Page> list = null;
            if (pages != null)
            {
                var pageIds = pages.Select(o => o.id).AsEnumerable();
                var fileBll = new BLL.File();
                var files = fileBll.GetFileInfos(pageIds);
                var tagBll = new BLL.Tag();
                var tags = tagBll.GetPageTags(pageIds);
                if (files != null)
                {
                    var imgs = (from f in files
                                select new Photo.Web.Models.Img
                                {
                                    Id = f.id,
                                    Url = f.url,
                                    Path = f.path,
                                    PageId = f.PageId,
                                    Width = f.width,
                                    Height = f.height
                                }).ToList();
                    list = (from p in pages
                            select new Photo.Web.Models.Page
                            {
                                Id = p.id,
                                AddTime = p.add_time,
                                Title = p.title,
                                Description = p.description,
                                DefaultImg = imgs.FirstOrDefault(o => o.PageId == p.id),
                            }).ToList();

                    list.ForEach(p =>
                    {
                        p.Tags = (from t in tags
                                  where t.PageID == p.Id
                                  select new Web.Models.Tag
                                  {
                                      ID = t.id,
                                      Name = t.tag,
                                      Citations = t.citations
                                  }).ToList();
                    });
                }
            }
            return View(list);
        }
Ejemplo n.º 2
0
        //
        // GET: /Page/
        public ActionResult Index()
        {
            RoteValueHelper rvh = new RoteValueHelper();
            var pageId = rvh.GetInt("pageId", 1);

            var pageBll = new BLL.Page();
            var tagBll = new BLL.Tag();
            var fileBll = new BLL.File();
            Models.Page page = null;
            try
            {
                var pageInfo = pageBll.GetPage(pageId);
                var tagInfos = tagBll.GetPageTags(pageId);
                var imgs = fileBll.GetFileInfos(pageId);

                page = new Models.Page
                {
                    Title = pageInfo.title,
                    AddTime = pageInfo.add_time
                };
                page.Tags = (from t in tagInfos
                             select new Models.Tag
                             {
                                 ID = t.id,
                                 Name = t.tag
                             }).ToList();
                page.Imgs = (from i in imgs
                             select new Models.Img
                             {
                                 Id = i.id,
                                 Path = i.path
                             }).ToList();
            }
            catch (Exception ex) { }
            return View(page);
        }