public void NewInfoService_GetNewInfoList_Test()
        {
            SearchNewInfoModel snmodel = new SearchNewInfoModel();

            snmodel.PagedIndex = 0;
            snmodel.PagedSize  = 10;
            List <NewInfoModel> resultModel = this._newInfoService.GetNewInfoList(snmodel).Data;

            Assert.IsTrue(true);
        }
Beispiel #2
0
        /// <summary>
        /// 列表Banner
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult List(SearchNewInfoModel model)
        {
            model.PagedIndex = model.PagedIndex == 0 ? 0 : model.PagedIndex;
            model.PagedSize  = model.PagedSize == 0 ? 10 : model.PagedSize;



            //列表查询
            var result             = this._newInfoService.GetNewInfoList(model);
            List <NewInfoModel> ds = result.Data;
            var data = new
            {
                rows  = ds,
                total = ds.Count,
            };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        /// <summary>
        /// 获取新闻信息表 wuyf
        /// </summary>
        /// <param name="model">model</param>
        /// <returns>新闻信息表</returns>
        public ResultModel GetNewInfoList(SearchNewInfoModel model)
        {
            var tb = _database.Db.NewInfo;

            var where = new SimpleExpression(1, 1, SimpleExpressionType.Equal); //

            if (model.NewInfoId > 0)
            {
                //ID
                where = new SimpleExpression(where, tb.NewInfoId == model.NewInfoId, SimpleExpressionType.And);
            }
            if (model.IsRecommend != 10)
            {
                //IsRecommend 是否推荐
                where = new SimpleExpression(where, tb.IsRecommend == model.IsRecommend, SimpleExpressionType.And);
            }
            if (!string.IsNullOrEmpty(model.NewTitle))
            {
                //新闻标题model.NewTitle.Trim() 这里不用Trim是为了英文
                where = new SimpleExpression(where, tb.NewTitle.Like("%" + model.NewTitle + "%"), SimpleExpressionType.And);
            }
            if (model.NewType > 0)
            {
                //新闻类型
                where = new SimpleExpression(where, tb.NewType == model.NewType, SimpleExpressionType.And);
            }


            //dynamic pc;

            var query = tb
                        .Query()

                        //.LeftJoin(_database.Db.YH_User, out pc)
                        //.On(_database.Db.YH_User.UserID == tb.UserID)
                        .Select(
                tb.NewInfoId,
                tb.NewType,
                tb.NewTitle,
                tb.NewContent,
                tb.IsRecommend,
                tb.NewImage,
                tb.CreateBy,
                tb.CreateDT,
                tb.UpdateBy,
                tb.UpdateDT

                //pc.Phone,
                //pc.RealName,
                //pc.Account
                )
                        .Where(where)
                        .OrderByCreateDTDescending();

            var result = new ResultModel
            {
                Data = new SimpleDataPagedList <NewInfoModel>(query,
                                                              model.PagedIndex, model.PagedSize)
            };

            return(result);
        }