Пример #1
0
        public HttpResponseMessage GetJKYMsgs([FromBody] GetJKYMsg m)
        {
            var filter = new BsonDocument();
            int Count  = MongoDbHelper.GetCount <Msg_J>(DbName.Msg_J, filter);

            if (Count == 0)
            {
                return(ResultHelper.OK(new List <string>()));
            }
            var ms = MongoDbHelper.GetPagedList2 <Msg_J, string>(DbName.Msg_J, m.Skip, m.Limit, filter, w => w.pt);//分页查找所有消息
            List <CreateMsg> lm = new List <CreateMsg>();

            for (int i = 0; i < ms.Count; i++)
            {
                var       u  = MongoDbHelper.QueryOne <U_Info>(DbName.U_Info, w => w._id == ms[i].pp);//发布者信息
                CreateMsg mg = new CreateMsg();
                mg.ID          = ms[i]._id.ToString();
                mg.Title       = ms[i].tt;
                mg.PublishName = u.pnm;
                mg.Time        = ms[i].pt;
                mg.Content     = ms[i].ct;
                mg.Urls        = ms[i].urls;
                lm.Add(mg);
            }
            return(ResultHelper.OK(new { Data = lm, Count = Count }));
        }
Пример #2
0
        public HttpResponseMessage GetArea([FromBody] GetJKYMsg m)
        {
            var filter = new BsonDocument();

            filter.Add("tp", 2);

            int Count = MongoDbHelper.GetCount <U_Info>(DbName.U_Info, filter);

            if (Count == 0)
            {
                return(ResultHelper.OK(""));
            }
            var         schs = MongoDbHelper.GetPagedList2 <U_Info, string>(DbName.U_Info, m.Skip, m.Limit, filter, w => w._id);
            List <User> lu   = new List <Models.User>();

            for (int i = 0; i < schs.Count; i++)
            {
                Models.User su = new Models.User()
                {
                    ID         = schs[i]._id,
                    Email      = schs[i].em,
                    PersonName = schs[i].pnm,
                    QQ         = schs[i].qq,
                    SchoolName = schs[i].snm,
                    Tel        = schs[i].ph,
                    AreaID     = schs[i].area,
                    Area       = Dict.Area.GetVal(schs[i].area)
                };
                lu.Add(su);
            }
            return(ResultHelper.OK(new { Data = lu, Count = Count }));
        }