Esempio n. 1
0
        /// <summary>
        /// 获取已上报的行政村防汛防台形势图列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public BsTableDataSource <VillagePicViewModel> GetVillagePicList(GetVillagePicList request)
        {
            using (var db = DbFactory.Open())
            {
                var builder = db.From <VillagePic2>();
                if (request.year == 0)
                {
                    throw new Exception("年度不正确");
                }

                builder.LeftJoin <VillagePic2, ADCDInfo>((x, y) => x.Adcd == y.adcd);
                builder.Where(x => x.Year == request.year && x.Adcd.StartsWith(adcd.Substring(0, 9)) && x.Adcd != adcd);
                if (!string.IsNullOrEmpty(request.adnm))
                {
                    builder.And <ADCDInfo>(y => y.adnm.Contains(request.adnm));
                }
                builder.Select <VillagePic2, ADCDInfo>((x, y) => new { Id = x.id, adcd = x.Adcd, adnm = y.adnm, PicName = x.PicName, Year = x.Year, CreatTime = x.CreatTime, operateLog = x.operateLog });
                var count = db.Select(builder).Count;
                if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) && request.Order == "asc")
                {
                    builder.OrderBy(x => request.Sort);
                }
                else if (!string.IsNullOrEmpty(request.Sort) && !string.IsNullOrEmpty(request.Order) &&
                         request.Order == "desc")
                {
                    builder.OrderByDescending(x => request.Sort);
                }
                else
                {
                    builder.OrderBy(x => x.Adcd);
                }

                var rows = request.PageSize == 0 ? 10 : request.PageSize;
                var skip = request.PageIndex == 0 ? 0 : (request.PageIndex - 1) * rows;

                builder.Limit(skip, rows);
                var list = db.Select <VillagePicViewModel>(builder);
                return(new BsTableDataSource <VillagePicViewModel>()
                {
                    total = count, rows = list
                });
            }
        }
Esempio n. 2
0
 public BsTableDataSource <VillagePicViewModel> Get(GetVillagePicList request)
 {
     return(VillagePicManager.GetVillagePicList(request));
 }