public FromMeModel GetFromMe(int userId, MessageSort sortedBy, bool des, PagerModel pager, int? projectId = null, int? addresseeId = null)
        {
            FromMeModel model = new FromMeModel();

            model.Messages = new List<FromMeItemModel>
            {
                new FromMeItemModel
                {
                    Id=11,
                    PublishTime=new DateTime(2015,1,13,12,11,0),
                    Project=getProject(1),
                    Task=new ViewModel.Task.LiteItemModel{ Id=3, Title="引入留言功能" },
                    Addressee=new UserModel{Id=14, Name="叶子" },
                    Content="人口结构失调为代价的,后者带来的问题"
                },
                new FromMeItemModel
                {
                    Id=21,
                    PublishTime=new DateTime(2015,1,12,12,31,0),
                    Project=getProject(2),
                    Task=new ViewModel.Task.LiteItemModel{ Id=23, Title="在BuildDatabase中准备好数据" },
                    Addressee=new UserModel{ Id=24,Name="叶子" },
                    Content="2010年,第六次人口普查显示:0—14岁儿童占总人口的16.60%。"
                },
                new FromMeItemModel
                {
                    Id=31,
                    PublishTime=new DateTime(2015,1,11,1,11,0),
                    ReadTime=new DateTime(2015,1,11,11,12,10),
                    Project=getProject(3),
                    Task=new ViewModel.Task.LiteItemModel{ Id=33, Title="准备数据" },
                    Addressee=new UserModel{ Id=34,Name="自由飞" },
                    Content="重心明显移后,劳动人口的绝对数量开始步入下降通道"
                },
                new FromMeItemModel
                {
                    Id=41,
                    PublishTime=new DateTime(2015,1,11,1,11,0),
                    ReadTime=new DateTime(2015,1,11,1,13,0),
                    Project=getProject(4),
                    Task=new ViewModel.Task.LiteItemModel{ Id=43, Title="实现统计的NHQuery方法" },
                    Addressee=new UserModel{ Id=44,Name="心情" },
                    Content="农村“一孩半”生育政策恰是出生性别比失调的主要原因"
                }
            };
            model.Addressees = model.Messages.Select(m => m.Addressee).Distinct().ToList();
            model.Projects = model.Messages.Select(m => m.Project).ToList();

            return model;
        }
        public ToMeModel GetToMe(int userId, MessageSort sortedBy, bool des, PagerModel pager, int? projectId = null, int? addresserId = null)
        {
            ToMeModel model = new ToMeModel();

            model.Messages = new List<ToMeItemModel>
            {
                new ToMeItemModel
                {
                    Id=11,
                    PublishTime=new DateTime(2015,1,13,12,11,0),
                    Project=getProject(1),
                    Task=new ViewModel.Task.LiteItemModel{ Id=3, Title="编辑任务时不能修改项目组" },
                    Addresser=new UserModel{Id=14, Name="叶子" },
                    Content="发布时改变下拉列表值也不能生效"
                },
                new ToMeItemModel
                {
                    Id=21,
                    PublishTime=new DateTime(2015,1,12,12,31,0),
                    Project=getProject(2),
                    Task=new ViewModel.Task.LiteItemModel{ Id=23, Title="博客页面的“上一篇”“下一篇”部分报错" },
                    Addresser=new UserModel{ Id=24,Name="叶子" },
                    Content="ViewModel冲突:Main.Blog.BlogPreAndNextModel和Main.PreAndNextModel"
                },
                new ToMeItemModel
                {
                    Id=31,
                    PublishTime=new DateTime(2015,1,11,1,11,0),
                    ReadTime=new DateTime(2015,1,11,11,12,10),
                    Project=getProject(3),
                    Task=new ViewModel.Task.LiteItemModel{ Id=33, Title="准备数据" },
                    Addresser=new UserModel{ Id=34,Name="自由飞" },
                    Content="重心明显移后,劳动人口的绝对数量开始步入下降通道"
                },
                new ToMeItemModel
                {
                    Id=41,
                    PublishTime=new DateTime(2015,1,11,1,11,0),
                    ReadTime=new DateTime(2015,1,11,1,13,0),
                    Project=getProject(4),
                    Task=new ViewModel.Task.LiteItemModel{ Id=43, Title="整理/Blog/{bloggerName} " },
                    Addresser=new UserModel{ Id=44,Name="心情" },
                    Content="整理/Blog/{bloggerName},能跑起来,先"
                }
            };
            model.Addressers = model.Messages.Select(m => m.Addresser).Distinct().ToList();
            model.Projects = new List<_LiteralLinkedModel>();

            return model;
        }
        public FromMeModel GetFromMe(int userId,
            MessageSort sortedBy, bool des,
            PagerModel pager,
            int? projectId = null, int? addresseeId = null)
        {
            FromMeModel model = new FromMeModel();

            model.Addressees = getCommunicators(userId, MessageFor.Addresser);
            model.Projects = getProjects(userId, MessageFor.Addresser);

            var messages = _querySource.Get(userId, addresseeId, projectId, MessageFor.Addresser)
                .Sort(sortedBy, des)
                .Paged(pager)
                .ToList();

            model.Messages = new List<FromMeItemModel>();
            model.Messages.FilledBy(messages);

            return model;
        }
Esempio n. 4
0
 private IEnumerable<FullItemModel> Paged(IEnumerable<FullItemModel> items, PagerModel pager)
 {
     return items
         .Skip(pager.PageSize * (pager.PageIndex - 1))
         .Take(pager.PageSize);
 }
        public PartialViewResult _Pager(PagerModel model)
        {
            #region format the url

            string path = Request.Url.LocalPath;
            int start = path.LastIndexOf("Page-");
            string pathPrefix = start > -1 ? path.Substring(0, start) : path;

            if (!pathPrefix.EndsWith("/"))
            {
                pathPrefix += "/";
            }

            model.FormatUrl = pathPrefix + "Page-{0}" + Request.Url.Query;

            #endregion

            return PartialView(model);
        }