Example #1
0
        public BsTableDataSource <VillageGridViewModel> GetVillageGrid(QRVillageGrid request)
        {
            using (var db = DbFactory.Open())
            {
                var builder = db.From <VillageGridPersonLiable>();
                builder.LeftJoin <VillageGridPersonLiable, ADCDInfo>((x, y) => x.VillageADCD == y.adcd);
                var _year = null != request.year ? request.year : System.DateTime.Now.Year;
                builder.Where <VillageGridPersonLiable>(x => x.Year == _year && x.VillageADCD == request.adcd);
                builder.Select(" VillageGridPersonLiable.*,ADCDInfo.adnm");
                var count = db.Count(builder);

                if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "asc")
                {
                    builder.OrderBy(o => request.Sort);
                }
                else if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "desc")
                {
                    builder.OrderByDescending(o => request.Sort);
                }
                else
                {
                    builder.OrderBy(o => o.ID);
                }

                var PageSize  = request.PageSize == 0 ? 15 : request.PageSize;
                var PageIndex = request.PageIndex == 0 ? 0 : (request.PageIndex) * PageSize;
                builder.Limit(PageIndex, PageSize);
                var RList = db.Select <VillageGridViewModel>(builder);

                return(new BsTableDataSource <VillageGridViewModel>()
                {
                    rows = RList, total = count
                });
            }
        }
Example #2
0
 public BsTableDataSource <VillageGridViewModel> GET(QRVillageGrid request)
 {
     return(QRCodeManager.GetVillageGrid(request));
 }