Пример #1
0
        private IQueryable<ThongTinGiaBaoModel> BuildQuery(ThongTinGiaBaoSearchModel search, string idBao, int status = 1, List<string> lstInclude = null)
        {
            string include = string.Empty;
            IQueryable<BThongTinGiaBao> qThongTinGiaBao = db.BThongTinGiaBaos;
            if (lstInclude != null && lstInclude.Count > 0)
                foreach (string item in lstInclude)
                    qThongTinGiaBao = qThongTinGiaBao.Include(item);

            IQueryable<ThongTinGiaBaoModel> query = (from u in qThongTinGiaBao//.Include(a=>a.)
                                                      where u.Status == status && u.ThongTinBaoId == idBao
                                                      select new ThongTinGiaBaoModel()
                                                      {
                                                          Id = u.Id,
                                                          ThongTinBaoId = u.ThongTinBaoId,
                                                          NgayHieuLuc = u.NgayHieuLuc,
                                                          NgayHetHieuLuc = u.NgayHetHieuLuc,
                                                          ProvinceCode = u.ProvinceCode,
                                                          QuyetDinh = u.QuyetDinh,
                                                          ValueType = u.ValueType,
                                                          Value = u.Value.ToString(),
                                                          MaBao = u.BThongTinBao != null ? u.BThongTinBao.MaBao : "",
                                                          TenBao = u.BThongTinBao != null ? u.BThongTinBao.TenBao : "",
                                                          BaoTrungUongDiaPhuong =  u.BThongTinBao.BaoTrungUongDiaPhuong,
                                                          BaoTrongMucLuc = u.BThongTinBao.BaoTrongMucLuc
                                                      }).OrderBy(a => a.Id);
            //Neu co include thi them include vao
            if (lstInclude != null && lstInclude.Count > 0)
                foreach (string item in lstInclude)
                    qThongTinGiaBao = qThongTinGiaBao.Include(item);
            if (search != null)
            {
                if (!string.IsNullOrWhiteSpace(search.Search))
                {
                    //string giaFrom = search.Search.Trim().Split(',')[0];
                    //string giaTo = search.Search.Trim().Split(',')[1];
                    //query = query.Where(a => Convert.ToDecimal(a.Value) >= Convert.ToDecimal(giaFrom) && Convert.ToDecimal(a.Value) <= Convert.ToDecimal(giaTo));
                    query = query.Where(a => a.MaBao.Contains(search.Search) || a.TenBao.Contains(search.Search));
                }
                if (!string.IsNullOrWhiteSpace(search.Value))
                    query = query.Where(a=>a.Value.CompareTo(search.Value)==0);
                if (!string.IsNullOrWhiteSpace(search.Id))
                    query = query.Where(a => a.Id.CompareTo(search.Id) == 0);
                if (!string.IsNullOrWhiteSpace(search.ThongTinBaoId))
                    query = query.Where(a => a.ThongTinBaoId.Contains(search.ThongTinBaoId));

            }
            return query;
        }
Пример #2
0
        private IQueryable<BThongTinGiaBaoModel> BuildQuery(ThongTinGiaBaoSearchModel search, int status = 1, List<string> lstInclude = null)
        {
            string include = string.Empty;
            IQueryable<BThongTinGiaBao> qThongTinGiaBao = db.BThongTinGiaBaos;
            if (lstInclude != null && lstInclude.Count > 0)
                foreach (string item in lstInclude)
                    qThongTinGiaBao = qThongTinGiaBao.Include(item);

            IQueryable<BThongTinGiaBaoModel> query = (from u in qThongTinGiaBao//.Include(a=>a.)
                                                      where u.Status == status
                                                      select new BThongTinGiaBaoModel()
                                                      {
                                                          Id = u.Id,
                                                          ThongTinBaoId = u.ThongTinBaoId,
                                                          NgayHieuLuc = u.NgayHieuLuc,
                                                          NgayHetHieuLuc = u.NgayHetHieuLuc,
                                                          ProvinceCode = u.ProvinceCode,
                                                          QuyetDinh = u.QuyetDinh,
                                                          ValueType = u.ValueType,
                                                          Value = u.Value,
                                                          MaBao = u.BThongTinBao != null ? u.BThongTinBao.MaBao : "",
                                                          TenBao = u.BThongTinBao != null ? u.BThongTinBao.TenBao : ""
                                                      }).OrderBy(a => a.ThongTinBaoId);
            //Neu co include thi them include vao
            if (lstInclude != null && lstInclude.Count > 0)
                foreach (string item in lstInclude)
                    qThongTinGiaBao = qThongTinGiaBao.Include(item);
            if (search != null)
            {
                if (!string.IsNullOrWhiteSpace(search.Id))
                    query = query.Where(a => a.Id.CompareTo(search.Id) == 0);
                if (!string.IsNullOrWhiteSpace(search.ThongTinBaoId))
                    query = query.Where(a => a.ThongTinBaoId.Contains(search.ThongTinBaoId));

            }
            return query;
        }
Пример #3
0
 public List<ThongTinGiaBaoModel> searchThongTinGiaBao(ThongTinGiaBaoSearchModel thongTinGiaBaoSearchModel)
 {
     int active = (int)Enums.RecordStatusCode.active;
     return BuildQuery(thongTinGiaBaoSearchModel, null, active, null).ToList();
 }
Пример #4
0
 public List<BThongTinGiaBaoModel> searchThongTinGiaBao(ThongTinGiaBaoSearchModel thongTinGiaBaoSearchModel)
 {
     int active = (int)Enums.RecordStatusCode.active;
     return BuildQuery(thongTinGiaBaoSearchModel, active, null).ToList();
     // throw new NotImplementedException();
 }