public BsTableDataSource <CountryPersonServiceModel> GetCountryPersonList(NoVerifyGetCountryPersonList request)
        {
            using (var db = DbFactory.Open())
            {
                if (request.year == null)
                {
                    throw new Exception("年度异常");
                }
                var bulider = db.From <CountryPerson>();
                //搜索部分判断

                if (!string.IsNullOrEmpty(request.adcd))
                {
                    bulider.Where(x => x.adcd == request.adcd);
                }
                if (null != request.nums && request.nums > 1)
                {
                    bulider.Where(x => x.AuditNums == request.nums);
                }
                if (!string.IsNullOrEmpty(request.Id.ToString()) && request.Id != 0)
                {
                    bulider.And(x => x.Id == request.Id);
                }
                if (!string.IsNullOrEmpty(request.name))
                {
                    bulider.And(x => x.UserName == request.name);
                }
                if (!string.IsNullOrEmpty(request.Position))
                {
                    bulider.And(x => x.Position == request.Position);
                }
                if (!string.IsNullOrEmpty(request.Post))
                {
                    bulider.And(x => x.Post == request.Post);
                }

                if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "asc")
                {
                    bulider.OrderBy(x => request.Sort);
                }
                else if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "desc")
                {
                    bulider.OrderByDescending(x => request.Sort);
                }
                else
                {
                    bulider.OrderByDescending(x => x.UpdateTime);
                }

                bulider.And(w => w.Year == request.year);
                var count     = db.Count(bulider);
                var PageSize  = request.PageSize == 0 ? 15 : request.PageSize;
                var PageIndex = request.PageIndex == 0 ? 0 : (request.PageIndex) * PageSize;
                bulider.Limit(PageIndex, PageSize);
                var list = db.Select <CountryPersonServiceModel>(bulider);
                return(new BsTableDataSource <CountryPersonServiceModel> {
                    rows = list, total = count
                });
            }
        }
Пример #2
0
 public BsTableDataSource <CountryPersonServiceModel> Get(NoVerifyGetCountryPersonList request)
 {
     return(CountryPerson.GetCountryPersonList(request));
 }