public bool CanHandle(MethodInfo method) { if (MethodSpec == null || MethodSpec.MethodBody == null) return false; var builder = new PredicateBuilder(); builder.MatchCovariantParameterTypes = false; builder.MatchCovariantReturnType = false; builder.MatchParameterTypes = true; builder.ArgumentTypes.AddRange(MethodSpec.ParameterTypes); builder.ReturnType = MethodSpec.ReturnType; // Find the method that matches the given name or // the alias var methodNames = new List<string>(); methodNames.Add(MethodSpec.MethodName); if (MethodSpec.Aliases.Count > 0) methodNames.AddRange(MethodSpec.Aliases); var found = false; var itemList = new[] { method }; foreach (var name in methodNames) { var candidates = itemList.AsFuzzyList(); builder.MethodName = name; builder.AddPredicates(candidates); var match = candidates.BestMatch(); if (match == null) continue; found = true; break; } return found; }
public async Task <byte[]> ExportPortfolio(SearchPortfolio searchPortfolio = null) { try { var comlumHeadrs = new string[] { Model.Resources.Common.PortfolioName, Model.Resources.Common.PortfolioContent, Model.Resources.Common.KVRRName }; var predicate = PredicateBuilder.New <Portfolio>(true); if (searchPortfolio != null) { if (!string.IsNullOrWhiteSpace(searchPortfolio.PortfolioName)) { predicate = predicate.And(u => !string.IsNullOrWhiteSpace(u.Title) && u.Title.Contains(searchPortfolio.PortfolioName)); } if (!string.IsNullOrWhiteSpace(searchPortfolio.PortfolioContent)) { predicate = predicate.And(u => !string.IsNullOrWhiteSpace(u.Content) && u.Content.Contains(searchPortfolio.PortfolioContent)); } if (!string.IsNullOrWhiteSpace(searchPortfolio.KVRRName)) { predicate = predicate.And(u => u.KVRRPortfolios != null && u.KVRRPortfolios.Any() && u.KVRRPortfolios.First().KVRR != null && !string.IsNullOrWhiteSpace(u.KVRRPortfolios.First().KVRR.Name) && u.KVRRPortfolios.First().KVRR.Name.Contains(searchPortfolio.KVRRName)); } } var listPortfolio = _unitOfWork.PortfolioRepository.GetAllPortfolio().Where(predicate).ToList(); using (var package = new ExcelPackage()) { var worksheet = package.Workbook.Worksheets.Add("Portfolios"); using (var cells = worksheet.Cells[1, 1, 1, 3]) { cells.Style.Font.Bold = true; } for (var i = 0; i < comlumHeadrs.Count(); i++) { worksheet.Cells[1, i + 1].Value = comlumHeadrs[i]; } var j = 2; foreach (var portfolio in listPortfolio) { worksheet.Cells["A" + j].Value = portfolio.Title; worksheet.Cells["B" + j].Value = portfolio.Content; worksheet.Cells["C" + j].Value = portfolio.KVRRPortfolios != null && portfolio.KVRRPortfolios.Any() ? portfolio.KVRRPortfolios.First().KVRR.Name : string.Empty; j++; } return(package.GetAsByteArray()); } } catch (Exception ex) { throw new ApplicationException("Export Portfolio: " + ex.Message); } }
public async Task <List <Product> > GetAllWithFilter(ProductFilter productFilter) { Expression <Func <Product, bool> > filter = null; Func <IQueryable <Product>, IOrderedQueryable <Product> > ordeBy = null; int?skip = null; int?take = 25; if (!string.IsNullOrWhiteSpace(productFilter.Name)) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.Name == productFilter.Name); } if (productFilter.Id != Guid.Empty) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.Id == productFilter.Id); } if (productFilter.IdCategoryProduct != Guid.Empty) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.CategoryProduct.Id == productFilter.IdCategoryProduct); } if (!string.IsNullOrWhiteSpace(productFilter.Description)) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.Description == productFilter.Description); } if (productFilter.Kosher) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.Kosher == productFilter.Kosher); } if (productFilter.Vegan) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.Vegan == productFilter.Vegan); } if (productFilter.Vegetarian) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.Vegetarian == productFilter.Vegetarian); } if (!string.IsNullOrWhiteSpace(productFilter.NameCategoryProduct)) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.CategoryProduct.Name == productFilter.NameCategoryProduct); } if (productFilter.CreatedAt.Year > 1) { if (filter == null) { filter = PredicateBuilder.New <Product>(true); } filter = filter.And(x => x.Id == productFilter.Id); } if (productFilter.PageIndex != null) { if (productFilter.PageIndex > 1) { skip = productFilter.PageIndex * 25; } } if (productFilter.PageSize != null) { if (productFilter.PageSize > 0) { take = productFilter.PageSize; } } if (!string.IsNullOrWhiteSpace(productFilter.Order)) { switch (productFilter.Order) { case "Id": ordeBy = x => x.OrderBy(n => n.Id); break; case "Name": ordeBy = x => x.OrderBy(n => n.Name); break; case "Description": ordeBy = x => x.OrderBy(n => n.Description); break; case "Price": ordeBy = x => x.OrderBy(n => n.Price); break; case "CreatedAt": ordeBy = x => x.OrderBy(n => n.CreatedAt); break; } } return(await _unitOfWork .RepositoryFactory .ProductRepository .Search( filter, ordeBy, skip, take)); }
private static void InitLazyExtensions() { LazyExtensions = new Lazy <IEnumerable <ExtensionDescriptor> >(() => WingExtensionAssemblies(PredicateBuilder.True <Wing>()).Select(Create)); }
public async Task <object> Export([FromUri] DemographicSearchViewModel pager) { try { if (pager == null) { pager = new DemographicSearchViewModel(); } var query = _context.DemographicChanges; var pred = PredicateBuilder.True <DemographicChange>(); if (!string.IsNullOrWhiteSpace(pager.Name)) { pred = pred.And(p => p.Name.Contains(pager.Name)); } if (!string.IsNullOrWhiteSpace(pager.FinderNumber)) { pred = pred.And(p => p.FinderNumber.Contains(pager.FinderNumber)); } if (!string.IsNullOrWhiteSpace(pager.LookupId)) { pred = pred.And(p => p.LookupId.Contains(pager.LookupId)); } if (!string.IsNullOrWhiteSpace(pager.City)) { pred = pred.And(p => p.State.StartsWith(pager.City)); } if (!string.IsNullOrWhiteSpace(pager.State)) { pred = pred.And(p => p.State.StartsWith(pager.State)); } if (!string.IsNullOrWhiteSpace(pager.Zipcode)) { pred = pred.And(p => p.Zipcode.StartsWith(pager.Zipcode)); } if (!string.IsNullOrWhiteSpace(pager.Email)) { pred = pred.And(p => p.Email.Contains(pager.Email)); } if (!string.IsNullOrWhiteSpace(pager.Phone)) { pred = pred.And(p => p.Phone.Contains(pager.Phone)); } if (pager.Source != null) { pred = pred.And(p => (int)p.Source == pager.Source); } var filteredQuery = query.Where(pred); var results = await filteredQuery.ProjectTo <DemographicViewModel>().ToListAsync(); var path = HttpContext.Current.Server.MapPath(@"~\app_data\demographiclist.csv"); using (var csv = new CsvWriter(new StreamWriter(File.Create(path)))) { csv.WriteHeader <DemographicChange>(); csv.WriteRecords(results); } var filename = $"demographic-changes-{DateTime.Now:u}.csv"; var response = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(path, FileMode.Open, FileAccess.Read); response.Content = new StreamContent(stream); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = filename }; response.Content.Headers.Add("x-filename", filename); return(ResponseMessage(response)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public List <MenuDto> GetMenuDtoList(string username, int cityid, int fxtCompanyId, LoginUser userInfo) { var allotFlowFilter = PredicateBuilder.True <AllotFlow>(); #region 小组权限 List <int> functionCodes = _unitOfWork.FunctionService.GetAllBy(userInfo.UserName, userInfo.FxtCompanyId, userInfo.NowCityId, WebCommon.Url_AllotFlowInfo_AllotFlowManager) .Select(m => m.FunctionCode).ToList(); //根据操作权限 if (functionCodes != null && functionCodes.Contains(SYSCodeManager.FunOperCode_3))//查看公司全部(管理员+分配人+审核人) { } else if (functionCodes != null && functionCodes.Contains(SYSCodeManager.FunOperCode_2))//查看小组内(组长) { var nowDepartmentUser = _unitOfWork.DepartmentUserRepository.Get(m => m.FxtCompanyID == userInfo.FxtCompanyId && m.CityID == userInfo.NowCityId && m.UserName == userInfo.UserName).FirstOrDefault(); if (nowDepartmentUser != null) { //小组下所有用户 var departmentUser = _unitOfWork.DepartmentUserRepository.Get() .Where(m => m.FxtCompanyID == userInfo.FxtCompanyId && m.CityID == userInfo.NowCityId && m.DepartmentID == nowDepartmentUser.DepartmentID).ToList(); var userids = departmentUser.Select(m => m.UserName); if (userids.Count() > 0) { allotFlowFilter = allotFlowFilter.And(m => userids.Contains(m.UserName) || userids.Contains(m.SurveyUserName) || m.SurveyUserName == userInfo.UserName || m.UserName == userInfo.UserName); } } } else//查看自己(查勘员) { allotFlowFilter = allotFlowFilter.And(m => m.UserName == userInfo.UserName || m.SurveyUserName == userInfo.UserName); } #endregion var roleUser = _unitOfWork.SysRoleUserRepository.Get(m => m.UserName == username && (m.CityID == cityid || m.CityID == 0) && (m.FxtCompanyID == fxtCompanyId || m.FxtCompanyID == 0)); var roleMenu = _unitOfWork.SysRoleMenuRepository.Get(m => (m.CityID == cityid || m.CityID == 0) && (m.FxtCompanyID == fxtCompanyId || m.FxtCompanyID == 0)); var menu = _unitOfWork.SysMenuRepository.Get(m => m.Valid == 1 && m.ModuleCode == 1001); var menus = ( from ru in roleUser join rm in roleMenu on ru.RoleID equals rm.RoleID join m in menu on rm.MenuID equals m.Id select m ).Distinct().ToList(); #region MenuDto List <MenuDto> menuDtod = new List <MenuDto>(); menus.ForEach((o) => { var dto = Mapper.Map <SYS_Menu, MenuDto>(o); switch (o.MenuName) { case "全部": var all = allotFlowFilter.And(m => m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(all).Count(); dto.ClassId = "all"; break; case "未分配任务": var wfp = allotFlowFilter.And(m => m.StateCode == SYSCodeManager.STATECODE_1 && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(wfp).Count(); dto.ClassId = "wfp"; break; case "已分配任务": var yfp = allotFlowFilter.And(m => (m.StateCode == SYSCodeManager.STATECODE_2 || m.StateCode == SYSCodeManager.STATECODE_4) && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(yfp).Count(); dto.ClassId = "yfp"; break; case "待查勘": var dck = allotFlowFilter.And(m => m.StateCode == SYSCodeManager.STATECODE_2 && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(dck).Count(); dto.ClassId = "dck"; break; case "查勘中": var ckz = allotFlowFilter.And(m => m.StateCode == SYSCodeManager.STATECODE_4 && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(ckz).Count(); dto.ClassId = "ckz"; break; case "已传回任务": var ych = allotFlowFilter.And(m => (m.StateCode == SYSCodeManager.STATECODE_5 || m.StateCode == SYSCodeManager.STATECODE_6 || m.StateCode == SYSCodeManager.STATECODE_8 || m.StateCode == SYSCodeManager.STATECODE_10) && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(ych).Count(); dto.ClassId = "ych"; break; case "已查勘": var yck = allotFlowFilter.And(m => m.StateCode == SYSCodeManager.STATECODE_5 && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(yck).Count(); dto.ClassId = "yck"; break; case "待审批": var dsp = allotFlowFilter.And(m => m.StateCode == SYSCodeManager.STATECODE_6 && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(dsp).Count(); dto.ClassId = "dsp"; break; case "审批已通过": var spytg = allotFlowFilter.And(m => m.StateCode == SYSCodeManager.STATECODE_8 && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(spytg).Count(); dto.ClassId = "spytg"; break; case "已入库": var yrk = allotFlowFilter.And(m => m.StateCode == SYSCodeManager.STATECODE_10 && m.CityId == cityid); dto.TotalCount = _unitOfWork.AllotFlowRepository.Get(yrk).Count(); dto.ClassId = "yrk"; break; default: dto.TotalCount = -1; break; } menuDtod.Add(dto); }); #endregion return(menuDtod); }
public async Task <IActionResult> GetScroll([FromBody] ScrollViewModel Scroll) { if (Scroll == null) { return(BadRequest()); } // Filter var filters = string.IsNullOrEmpty(Scroll.Filter) ? new string[] { "" } : Scroll.Filter.Split(null); var predicate = PredicateBuilder.False <CheckList>(); foreach (string temp in filters) { string keyword = temp; predicate = predicate.Or(x => x.NameEng.ToLower().Contains(keyword) || x.NameThai.ToLower().Contains(keyword) || x.Description.ToLower().Contains(keyword)); } if (!string.IsNullOrEmpty(Scroll.Where)) { predicate = predicate.And(p => p.Creator == Scroll.Where); } //Order by Func <IQueryable <CheckList>, IOrderedQueryable <CheckList> > order; // Order switch (Scroll.SortField) { case "NameThai": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.NameThai); } else { order = o => o.OrderBy(x => x.NameThai); } break; case "NameEng": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.NameEng); } else { order = o => o.OrderBy(x => x.NameEng); } break; case "Description": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.Description); } else { order = o => o.OrderBy(x => x.Description); } break; case "Date": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.CreateDate); } else { order = o => o.OrderBy(x => x.CreateDate); } break; default: order = o => o.OrderByDescending(x => x.CreateDate); break; } var QueryData = await this.repository.GetToListAsync( selector : selected => selected, // Selected predicate : predicate, // Where orderBy : order, // Order include : null, // Include skip : Scroll.Skip ?? 0, // Skip take : Scroll.Take ?? 10); // Take // Get TotalRow Scroll.TotalRow = await this.repository.GetLengthWithAsync(predicate : predicate); //var mapDatas = new List<CheckList>(); //foreach (var item in QueryData) //{ // var MapItem = this.mapper.Map<JobCardMaster, JobCardMasterViewModel>(item); // mapDatas.Add(MapItem); //} return(new JsonResult(new ScrollDataViewModel <CheckList>(Scroll, QueryData.ToList()), this.DefaultJsonSettings)); }
public Expression <Func <Domain.Entities.Seiyuu, bool> > BuildExpression(SearchSeiyuuQuery query) { var predicate = PredicateBuilder.True <Domain.Entities.Seiyuu>(); return(query != null?ExtendExpressionWithSearchCriteria(predicate, query) : predicate); }
protected override void VisitWhereNotEquals(Query.Expressions.WhereNotEqualsExpression expression) { LinqExpression = PredicateBuilder.And(LinqExpression, it => WhereNotEquals(it[expression.FieldName], expression.Value)); }
protected override void VisitWhereLessThanOrEqual(WhereLessThanOrEqualExpression expression) { LinqExpression = PredicateBuilder.And(LinqExpression, it => WhereLessThanOrEqual(it[expression.FieldName], expression.Value)); }
protected override void VisitWhereEndsWith(Query.Expressions.WhereEndsWithExpression expression) { LinqExpression = PredicateBuilder.And(LinqExpression, it => EndsWith(it[expression.FieldName], expression.Value)); }
protected override void VisitWhereBetween(Query.Expressions.WhereBetweenExpression expression) { LinqExpression = PredicateBuilder.And(LinqExpression, it => WhereBetween(it[expression.FieldName], expression.Start, expression.End)); }
public async Task <JsonResult> GetPageList() { var jm = new AdminUiCallBack(); var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1); var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30); var where = PredicateBuilder.True <SysRoleMenu>(); //获取排序字段 var orderField = Request.Form["orderField"].FirstOrDefault(); Expression <Func <SysRoleMenu, object> > orderEx; switch (orderField) { case "id": orderEx = p => p.id; break; case "roleId": orderEx = p => p.roleId; break; case "menuId": orderEx = p => p.menuId; break; case "createTime": orderEx = p => p.createTime; break; case "updateTime": orderEx = p => p.updateTime; break; default: orderEx = p => p.id; break; } //设置排序方式 var orderDirection = Request.Form["orderDirection"].FirstOrDefault(); var orderBy = orderDirection switch { "asc" => OrderByType.Asc, "desc" => OrderByType.Desc, _ => OrderByType.Desc }; //查询筛选 //主键 int var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0); if (id > 0) { @where = @where.And(p => p.id == id); } //角色id int var roleId = Request.Form["roleId"].FirstOrDefault().ObjectToInt(0); if (roleId > 0) { @where = @where.And(p => p.roleId == roleId); } //菜单id int var menuId = Request.Form["menuId"].FirstOrDefault().ObjectToInt(0); if (menuId > 0) { @where = @where.And(p => p.menuId == menuId); } //创建时间 datetime var createTime = Request.Form["createTime"].FirstOrDefault(); if (!string.IsNullOrEmpty(createTime)) { if (createTime.Contains("到")) { var dts = createTime.Split("到"); var dtStart = dts[0].Trim().ObjectToDate(); where = where.And(p => p.createTime > dtStart); var dtEnd = dts[1].Trim().ObjectToDate(); where = where.And(p => p.createTime < dtEnd); } else { var dt = createTime.ObjectToDate(); where = where.And(p => p.createTime > dt); } } //修改时间 datetime var updateTime = Request.Form["updateTime"].FirstOrDefault(); if (!string.IsNullOrEmpty(updateTime)) { if (updateTime.Contains("到")) { var dts = updateTime.Split("到"); var dtStart = dts[0].Trim().ObjectToDate(); where = where.And(p => p.updateTime > dtStart); var dtEnd = dts[1].Trim().ObjectToDate(); where = where.And(p => p.updateTime < dtEnd); } else { var dt = updateTime.ObjectToDate(); where = where.And(p => p.updateTime > dt); } } //获取数据 var list = await _sysRoleMenuServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize); //返回数据 jm.data = list; jm.code = 0; jm.count = list.TotalCount; jm.msg = "数据调用成功!"; return(new JsonResult(jm)); }
public async Task <JsonResult> QueryExportExcel() { var jm = new AdminUiCallBack(); var where = PredicateBuilder.True <SysRoleMenu>(); //查询筛选 //主键 int var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0); if (id > 0) { @where = @where.And(p => p.id == id); } //角色id int var roleId = Request.Form["roleId"].FirstOrDefault().ObjectToInt(0); if (roleId > 0) { @where = @where.And(p => p.roleId == roleId); } //菜单id int var menuId = Request.Form["menuId"].FirstOrDefault().ObjectToInt(0); if (menuId > 0) { @where = @where.And(p => p.menuId == menuId); } //创建时间 datetime var createTime = Request.Form["createTime"].FirstOrDefault(); if (!string.IsNullOrEmpty(createTime)) { var dt = createTime.ObjectToDate(); where = where.And(p => p.createTime > dt); } //修改时间 datetime var updateTime = Request.Form["updateTime"].FirstOrDefault(); if (!string.IsNullOrEmpty(updateTime)) { var dt = updateTime.ObjectToDate(); where = where.And(p => p.updateTime > dt); } //获取数据 //创建Excel文件的对象 var book = new HSSFWorkbook(); //添加一个sheet var sheet1 = book.CreateSheet("Sheet1"); //获取list数据 var listmodel = await _sysRoleMenuServices.QueryListByClauseAsync(where, p => p.id, OrderByType.Asc); //给sheet1添加第一行的头部标题 var row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("主键"); row1.CreateCell(1).SetCellValue("角色id"); row1.CreateCell(2).SetCellValue("菜单id"); row1.CreateCell(3).SetCellValue("创建时间"); row1.CreateCell(4).SetCellValue("修改时间"); //将数据逐步写入sheet1各个行 for (var i = 0; i < listmodel.Count; i++) { var rowtemp = sheet1.CreateRow(i + 1); rowtemp.CreateCell(0).SetCellValue(listmodel[i].id.ToString()); rowtemp.CreateCell(1).SetCellValue(listmodel[i].roleId.ToString()); rowtemp.CreateCell(2).SetCellValue(listmodel[i].menuId.ToString()); rowtemp.CreateCell(3).SetCellValue(listmodel[i].createTime.ToString()); rowtemp.CreateCell(4).SetCellValue(listmodel[i].updateTime.ToString()); } // 写入到excel var webRootPath = _webHostEnvironment.WebRootPath; var tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; var fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SysRoleMenu导出(查询结果).xls"; var filePath = webRootPath + tpath; var di = new DirectoryInfo(filePath); if (!di.Exists) { di.Create(); } var fileHssf = new FileStream(filePath + fileName, FileMode.Create); book.Write(fileHssf); fileHssf.Close(); jm.code = 0; jm.msg = GlobalConstVars.ExcelExportSuccess; jm.data = tpath + fileName; return(new JsonResult(jm)); }
protected override void OnTerm() { builder = null; }
public PurchaseOrderPusatResponse GetListData(PurchaseOrderPusatRequest request) { List <PurchaseOrderPusatModel> lists = new List <PurchaseOrderPusatModel>(); dynamic qry = null; var searchPredicate = PredicateBuilder.New <Data.DataRepository.PurchaseOrderPusat>(true); // add default filter to show the active data only searchPredicate = searchPredicate.And(x => x.RowStatus == 0); if ((GeneralHandler.authorized("APPROVE_M_PURCHASEORDERPUSAT") == "false")) { searchPredicate.And(x => x.approve >= 1); } if (!String.IsNullOrEmpty(request.SearchValue) && !String.IsNullOrWhiteSpace(request.SearchValue)) { searchPredicate = searchPredicate.And(p => p.ponumber.Contains(request.SearchValue)); } if (!(string.IsNullOrEmpty(request.SortColumn) && string.IsNullOrEmpty(request.SortColumnDir))) { if (request.SortColumnDir == "asc") { switch (request.SortColumn.ToLower()) { case "ponumber": qry = _unitOfWork.PurchaseOrderPusatRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.ponumber)); break; default: qry = _unitOfWork.PurchaseOrderPusatRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.id)); break; } } else { switch (request.SortColumn.ToLower()) { case "ponumber": qry = _unitOfWork.PurchaseOrderPusatRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.ponumber)); break; default: qry = _unitOfWork.PurchaseOrderPusatRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.id)); break; } } } else { qry = _unitOfWork.PurchaseOrderPusatRepository.Get(searchPredicate, null); } foreach (var item in qry) { var prData = new PurchaseOrderPusatModel { Id = item.id, PurchaseRequestId = item.PurchaseRequestId, ponumber = item.ponumber, podate = item.podate, approve_by = item.approve_by, approve = item.approve, request_by = item.request_by, ModifiedBy = item.ModifiedBy, CreatedBy = item.CreatedBy, ModifiedDate = item.ModifiedDate, createformat = GeneralHandler.FormatDate(item.CreatedDate) }; lists.Add(prData); } int totalRequest = lists.Count(); var data = lists.Skip(request.Skip).Take(request.PageSize).ToList(); var response = new PurchaseOrderPusatResponse { Draw = request.Draw, RecordsFiltered = totalRequest, RecordsTotal = totalRequest, Data = data }; return(response); }
protected override void VisitFalse(FalseExpression expression) { this.LinqExpression = PredicateBuilder.And(LinqExpression, it => false); }
/// <summary> /// 是否收藏此题目 /// </summary> /// <returns></returns> public ProblemCollect IsProblemCollect(int userInfoId, int problemId) { var where = PredicateBuilder.True <ProblemCollect>(); where = where.And(m => m.UserInfoId == userInfoId && m.ProblemId == problemId); return(this._repoProblemCollect.Table.Where(where).FirstOrDefault()); }
protected override void VisitTrue(TrueExpression expression) { this.LinqExpression = PredicateBuilder.And(LinqExpression, it => true); }
//[PartialCache("Short")] public ActionResult PostCategories(string virtualCategoryId, int page, string title, string attrs, string prices, string proattrs, string keywords , int?productOld, int?productNew) { var expression = PredicateBuilder.True <Post>(); expression = expression.And(x => x.Status == 1); var sortBuilder = new SortBuilder { ColumnName = "CreatedDate", ColumnOrder = SortBuilder.SortOrder.Descending }; var paging = new Paging { PageNumber = page, PageSize = PageSize, TotalRecord = 0 }; if (page == 1) { var viewBag = ViewBag; var postService = _postService; Expression <Func <Post, bool> > productNews = x => x.ProductNew && x.Status == (int)Status.Enable; viewBag.HotCard = postService.GetTop(3, productNews, x => x.CreatedDate).ToList(); } if (!string.IsNullOrEmpty(attrs)) { var strArrays = attrs.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var list = ( from s in strArrays select int.Parse(s)).ToList(); expression = expression.And(x => x.AttributeValues.Count(a => list.Contains(a.Id)) > 0); ViewBag.Attributes = list; } if (!string.IsNullOrEmpty(prices)) { var nums = ( from s in prices.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) select decimal.Parse(s)).ToList(); var item = nums[0]; var num = nums[1]; expression = expression.And(x => x.Price >= item && x.Price <= num); ViewBag.Prices = nums; } if (!string.IsNullOrEmpty(proattrs)) { var strArrays1 = proattrs.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var list1 = ( from s in strArrays1 select int.Parse(s)).ToList(); expression = expression.And(x => list1.Contains(x.Id)); ViewBag.ProAttributes = list1; } if (!string.IsNullOrEmpty(keywords)) { expression = expression.And(x => x.Title.Contains(keywords)); } expression = expression.And(x => x.VirtualCategoryId.Contains(virtualCategoryId)); if (productNew.HasValue) { expression = expression.And(x => !x.OldOrNew); ViewBag.ProductNew = productNew; } if (productOld.HasValue & productNew.HasValue) { expression = expression.Or(x => x.OldOrNew); ViewBag.ProductOld = productOld; } if (productOld.HasValue & !productNew.HasValue) { expression = expression.And(x => x.OldOrNew); ViewBag.ProductOld = productOld; } var posts = _postService.GetBySort(expression, sortBuilder, paging); IEnumerable <Post> postLocalized = null; if (posts.IsAny()) { postLocalized = posts.Select(x => x.ToModel()); var pageInfo = new Helper.PageInfo(ExtentionUtils.PageSize, page, paging.TotalRecord, i => Url.Action("GetContent", "Menu", new { page = i })); ViewBag.PageInfo = pageInfo; ViewBag.CountItem = pageInfo.TotalItems; ViewBag.MenuId = postLocalized.ElementAt(0).MenuId; } //Get menu category filter var menuCategoryFilter = _menuLinkService.GetByOption(virtualId: virtualCategoryId); if (menuCategoryFilter.IsAny()) { var lstBreadCrumb = new List <BreadCrumb>(); ViewBag.MenuCategoryFilter = menuCategoryFilter; //Lấy bannerId từ post để hiển thị banner trên post ViewBag.BannerId = menuCategoryFilter.FirstOrDefault(x => x.VirtualId == virtualCategoryId).Id; var categories = virtualCategoryId.Split('/'); for (var i = 0; i < categories.Length; i++) { //var str = categories[i]; var menuLink = _menuLinkService.GetByMenuName(categories[i], title); if (menuLink != null) { //Lấy bannerId từ post để hiển thị banner trên post if (i == 0) { ViewBag.BannerId = menuLink.Id; } lstBreadCrumb.Add(new BreadCrumb { Title = menuLink.GetLocalized(m => m.MenuName, menuLink.Id), Current = false, Url = Url.Action("GetContent", "Menu", new { area = "", menu = menuLink.SeoUrl }) }); } } lstBreadCrumb.Add(new BreadCrumb { Current = true, Title = title }); ViewBag.BreadCrumb = lstBreadCrumb; } ViewBag.Title = title; ViewBag.VirtualId = virtualCategoryId; return(PartialView(postLocalized)); }
public async Task <IActionResult> GetScroll([FromBody] ScrollViewModel Scroll) { var message = "Data not been found."; try { if (Scroll == null) { return(BadRequest()); } // Filter var filters = string.IsNullOrEmpty(Scroll.Filter) ? new string[] { "" } : Scroll.Filter.Split(null); var predicate = PredicateBuilder.False <Breed>(); foreach (string temp in filters) { string keyword = temp; predicate = predicate.Or(x => x.Name.ToLower().Contains(keyword) || x.Description.ToLower().Contains(keyword)); } // Order by Func <IQueryable <Breed>, IOrderedQueryable <Breed> > order; // Order switch (Scroll.SortField) { case "Name": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.Name); } else { order = o => o.OrderBy(x => x.Name); } break; case "Description": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.Description); } else { order = o => o.OrderBy(x => x.Description); } break; default: order = o => o.OrderBy(x => x.Name); break; } var QueryData = await this.repository.GetToListAsync( selector : selected => selected, // Selected predicate : predicate, // Where orderBy : order, // Order include : null, // Include skip : Scroll.Skip ?? 0, // Skip take : Scroll.Take ?? 50); // Take // Get TotalRow Scroll.TotalRow = await this.repository.GetLengthWithAsync(predicate : predicate); //var mapDatas = new List<ApprovedFlowMaster>(); //foreach (var item in QueryData) //{ // var MapItem = this.mapper.Map<JobCardMaster, JobCardMasterViewModel>(item); // mapDatas.Add(MapItem); //} return(new JsonResult(new ScrollDataViewModel <Breed>(Scroll, QueryData.ToList()), this.DefaultJsonSettings)); } catch (Exception ex) { message = $"Has error {ex.ToString()}"; } return(BadRequest(new { Error = message })); }
/// <summary> /// 分页列表 /// </summary> /// <param name="pagingUser">分页数据</param> /// <param name="roleID">角色ID</param> /// <param name="username">用户名</param> /// <param name="name">名称</param> /// <param name="sex">性别</param> /// <param name="email">Email</param> /// <param name="order">排序【null(默认)-ID降序,0-ID升序,1-ID降序,2-注册时间降序,3-注册时间升序,4-最后登录时间升序,5-最后登录时间降序】</param> /// <returns></returns> public Paging <User> FindPageList(Paging <User> pagingUser, int?roleID, string username, string name, int?sex, string email, int?order) { //查询表达式 var _where = PredicateBuilder.True <User>(); if (roleID != null && roleID > 0) { _where = _where.And(u => u.RoleID == roleID); } if (!string.IsNullOrEmpty(username)) { _where = _where.And(u => u.PhoneNumber.Contains(username)); } if (!string.IsNullOrEmpty(name)) { _where = _where.And(u => u.Name.Contains(name)); } if (sex != null && sex >= 0 && sex <= 2) { _where = _where.And(u => u.Sex == sex); } if (!string.IsNullOrEmpty(email)) { _where = _where.And(u => u.Email.Contains(email)); } //排序 OrderParam _orderParam; switch (order) { case 0: //ID升序 _orderParam = new OrderParam() { PropertyName = "UserID", Method = OrderMethod.ASC }; break; case 1: //ID降序 _orderParam = new OrderParam() { PropertyName = "UserID", Method = OrderMethod.DESC }; break; case 2: //注册时间升序 _orderParam = new OrderParam() { PropertyName = "RegTime", Method = OrderMethod.ASC }; break; case 3: //注册时间降序 _orderParam = new OrderParam() { PropertyName = "RegTime", Method = OrderMethod.DESC }; break; case 4: //最后登录时间升序 _orderParam = new OrderParam() { PropertyName = "LastLoginTime", Method = OrderMethod.ASC }; break; case 5: //最后登录时间降序 _orderParam = new OrderParam() { PropertyName = "LastLoginTime", Method = OrderMethod.DESC }; break; default: //ID降序 _orderParam = new OrderParam() { PropertyName = "UserID", Method = OrderMethod.DESC }; break; } pagingUser.Items = Repository.FindPageList(pagingUser.PageSize, pagingUser.PageIndex, out pagingUser.TotalNumber, _where.Expand(), _orderParam).ToList(); return(pagingUser); }
public List <LoketModel> GetbaseLoketData(LoketRequest request, Expression <Func <QueuePoli, bool> > searchCriteria = null) { List <LoketModel> lists = new List <LoketModel>(); dynamic qry = null; var searchPredicate = PredicateBuilder.New <QueuePoli>(true); searchPredicate = searchPredicate.And(searchCriteria); if (request.Data.PoliToID != 0) { searchPredicate = searchPredicate.And(p => p.PoliTo == request.Data.PoliToID); } if (request.Data.ClinicID != 0) { searchPredicate = searchPredicate.And(p => p.ClinicID == request.Data.ClinicID); } if (request.Data.Status != -1) { searchPredicate = searchPredicate.And(p => p.Status == request.Data.Status); } if (!string.IsNullOrEmpty(request.Data.strIsPreExamine)) { bool _isAlreadyPreExamine = Convert.ToBoolean(request.Data.strIsPreExamine); searchPredicate = searchPredicate.And(p => p.IsPreExamine == _isAlreadyPreExamine); } if (!String.IsNullOrEmpty(request.SearchValue) && !String.IsNullOrWhiteSpace(request.SearchValue)) { searchPredicate = searchPredicate.And(p => p.Patient.Name.Contains(request.SearchValue) || p.Doctor.Name.Contains(request.SearchValue) || p.Patient.MRNumber.Contains(request.SearchValue)); } if (!(string.IsNullOrEmpty(request.SortColumn) && string.IsNullOrEmpty(request.SortColumnDir))) { if (request.SortColumnDir == "asc") { switch (request.SortColumn.ToLower()) { case "patientname": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.Patient.Name)); break; case "doctorstr": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.Doctor.Name)); break; case "transactiondatestr": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.TransactionDate)); break; default: qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.ID)); break; } } else { switch (request.SortColumn.ToLower()) { case "patientname": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.Patient.Name)); break; case "doctorstr": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.Doctor.Name)); break; case "transactiondatestr": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.TransactionDate)); break; default: qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.ID)); break; } } } else { qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, null); } foreach (var item in qry) { LoketModel lokmdl = Mapper.Map <QueuePoli, LoketModel>(item); if (item.Type == (int)RegistrationTypeEnum.MCU) { lokmdl.SortNumberCode = "M-" + string.Format("{0:D3}", item.SortNumber); } else { lokmdl.SortNumberCode = item.Poli1.Code.Trim() + "-" + string.Format("{0:D3}", item.SortNumber); } lists.Add(lokmdl); } DateTime _start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); DateTime _end = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); lists = lists.Where(x => x.TransactionDate >= _start && x.TransactionDate <= _end).ToList(); int totalRequest = lists.Count(); var data = lists.Skip(request.Skip).Take(request.PageSize).ToList(); return(data); }
public async Task <object> Get([FromUri] DemographicSearchViewModel pager) { try { var stopwatch = new Stopwatch(); stopwatch.Restart(); if (pager == null) { pager = new DemographicSearchViewModel(); } var query = _context.DemographicChanges; var totalCount = await query.CountAsync(); var pred = PredicateBuilder.True <DemographicChange>(); if (!string.IsNullOrWhiteSpace(pager.Name)) { pred = pred.And(p => p.Name.Contains(pager.Name)); } if (!string.IsNullOrWhiteSpace(pager.FinderNumber)) { pred = pred.And(p => p.FinderNumber.Contains(pager.FinderNumber)); } if (!string.IsNullOrWhiteSpace(pager.LookupId)) { pred = pred.And(p => p.LookupId.Contains(pager.LookupId)); } if (!string.IsNullOrWhiteSpace(pager.City)) { pred = pred.And(p => p.State.StartsWith(pager.City)); } if (!string.IsNullOrWhiteSpace(pager.State)) { pred = pred.And(p => p.State.StartsWith(pager.State)); } if (!string.IsNullOrWhiteSpace(pager.Zipcode)) { pred = pred.And(p => p.Zipcode.StartsWith(pager.Zipcode)); } if (!string.IsNullOrWhiteSpace(pager.Email)) { pred = pred.And(p => p.Email.Contains(pager.Email)); } if (!string.IsNullOrWhiteSpace(pager.Phone)) { pred = pred.And(p => p.Phone.Contains(pager.Phone)); } if (pager.Source != null) { pred = pred.And(p => (int)p.Source == pager.Source); } var filteredQuery = query.Where(pred); var pagerCount = filteredQuery.Count(); var totalPages = Math.Ceiling((double)pagerCount / pager.PageSize ?? PAGE_SIZE); var results = await filteredQuery.Where(pred) .Order(pager.OrderBy, pager.OrderDirection == "desc" ? SortDirection.Descending : SortDirection.Ascending) .Skip(pager.PageSize * (pager.Page - 1) ?? 0) .Take(pager.PageSize ?? PAGE_SIZE) .ProjectTo <DemographicViewModel>().ToListAsync(); pager.TotalCount = totalCount; pager.FilteredCount = pagerCount; pager.TotalPages = totalPages; pager.Results = results; stopwatch.Stop(); pager.ElapsedTime = stopwatch.Elapsed; return(Ok(pager)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public List <LoketModel> GetFarmasiBaseLoketData(LoketRequest request, Expression <Func <QueuePoli, bool> > searchCriteria = null) { List <LoketModel> lists = new List <LoketModel>(); dynamic qry = null; var searchPredicate = PredicateBuilder.New <QueuePoli>(true); searchPredicate = searchPredicate.And(searchCriteria); if (request.Data.PoliToID != 0) { searchPredicate = searchPredicate.And(p => p.PoliTo == request.Data.PoliToID); } if (request.Data.ClinicID != 0) { searchPredicate = searchPredicate.And(p => p.ClinicID == request.Data.ClinicID); } if (!(string.IsNullOrEmpty(request.SortColumn) && string.IsNullOrEmpty(request.SortColumnDir))) { if (request.SortColumnDir == "asc") { switch (request.SortColumn.ToLower()) { case "patientname": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.Patient.Name)); break; case "doctorstr": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.Doctor.Name)); break; case "transactiondatestr": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.TransactionDate)); break; default: qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.ID)); break; } } else { switch (request.SortColumn.ToLower()) { case "patientname": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.Patient.Name)); break; case "doctorstr": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.Doctor.Name)); break; case "transactiondatestr": qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.TransactionDate)); break; default: qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.ID)); break; } } } else { qry = _unitOfWork.RegistrationRepository.Get(searchPredicate, null); } foreach (var item in qry) { // original loket long formMedicalID = ((QueuePoli)item).FormMedicalID.Value; QueuePoli sourcePoli = _unitOfWork.RegistrationRepository.GetFirstOrDefault(x => x.FormMedicalID == formMedicalID); LoketModel lokmdl = Mapper.Map <QueuePoli, LoketModel>(item); if (sourcePoli != null && sourcePoli.DoctorID != null) { lokmdl.DoctorID = sourcePoli.DoctorID.Value; lokmdl.DoctorStr = sourcePoli.Doctor != null ? sourcePoli.Doctor.Name : string.Empty; } if (item.Type == (int)RegistrationTypeEnum.MCU) { lokmdl.SortNumberCode = "M-" + string.Format("{0:D3}", item.SortNumber); } else { lokmdl.SortNumberCode = item.Poli1.Code.Trim() + "-" + string.Format("{0:D3}", item.SortNumber); } // modify the status lokmdl.StatusStr = ((PharmacyStatusEnum)lokmdl.Status).ToString(); lists.Add(lokmdl); } DateTime _start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); DateTime _end = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); lists = lists.Where(x => x.TransactionDate >= _start && x.TransactionDate <= _end).ToList(); int totalRequest = lists.Count(); var data = lists.Skip(request.Skip).Take(request.PageSize).ToList(); return(data); }
public ExtensionDescriptor GetExtension(string id) { return(WingExtensionAssemblies(PredicateBuilder.True <Wing>().And(w => w.WingGUID == Guid.Parse(id))) .Select(Create).FirstOrDefault()); }
public IHttpActionResult Export(int id, GuestSearchViewModel vm) { var ticketMailed = vm.IsMailed ?? false; var isWaiting = vm.IsWaiting ?? false; var isAttending = vm.IsAttending ?? false; var pred = PredicateBuilder.True <Guest>(); pred = pred.And(p => p.EventId == id); if (!string.IsNullOrWhiteSpace(vm.Address)) { pred = pred.And(p => p.Address.Contains(vm.Address)); } if (!string.IsNullOrWhiteSpace(vm.FinderNumber)) { pred = pred.And(p => p.FinderNumber.StartsWith(vm.FinderNumber)); } if (!string.IsNullOrWhiteSpace(vm.Name)) { pred = pred.And(p => p.Name.Contains(vm.Name)); } if (!string.IsNullOrWhiteSpace(vm.City)) { pred = pred.And(p => p.City.StartsWith(vm.City)); } if (!string.IsNullOrWhiteSpace(vm.State)) { pred = pred.And(p => p.State.Equals(vm.State)); } if (!string.IsNullOrWhiteSpace(vm.ZipCode)) { pred = pred.And(p => p.Zipcode.StartsWith(vm.ZipCode)); } if (!string.IsNullOrWhiteSpace(vm.Phone)) { pred = pred.And(p => p.Phone.Contains(vm.Phone)); } if (!string.IsNullOrWhiteSpace(vm.Email)) { pred = pred.And(p => p.Email.StartsWith(vm.Email)); } if (!string.IsNullOrWhiteSpace(vm.LookupId)) { pred = pred.And(p => p.LookupId.StartsWith(vm.LookupId)); } if (vm.IsMailed != null) { pred = pred.And(p => p.IsMailed == ticketMailed); } if (vm.IsWaiting != null) { pred = pred.And(p => p.IsWaiting == isWaiting); } if (vm.IsAttending != null) { pred = pred.And(p => p.IsAttending == isAttending); } var list = context.Guests.AsQueryable() .Where(pred) .ProjectTo <GuestExportViewModel>(); var path = HttpContext.Current.Server.MapPath(@"~\app_data\guestlist.csv"); using (var csv = new CsvWriter(new StreamWriter(File.Create(path)))) { csv.Configuration.RegisterClassMap <GuestExportMap>(); csv.WriteHeader <GuestExportViewModel>(); csv.WriteRecords(list); } var filename = $"guest-list-{DateTime.Now.ToString("u")}.csv"; var response = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(path, FileMode.Open, FileAccess.Read); response.Content = new StreamContent(stream); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = filename }; response.Content.Headers.Add("x-filename", filename); return(ResponseMessage(response)); }
public async Task <IActionResult> GetScroll([FromBody] ScrollViewModel Scroll) { if (Scroll == null) { return(BadRequest()); } var predicate = PredicateBuilder.False <AdjustStockSp>(); if (!string.IsNullOrEmpty(Scroll.Where)) { predicate = predicate.And(p => p.Creator == Scroll.Where); } // Filter var filters = string.IsNullOrEmpty(Scroll.Filter) ? new string[] { "" } : Scroll.Filter.ToLower().Split(null); foreach (var keyword in filters) { predicate = predicate.And(x => x.Description.ToLower().Contains(keyword) || x.Remark.ToLower().Contains(keyword) || x.SparePart.Name.ToLower().Contains(keyword)); } //Order by Func <IQueryable <AdjustStockSp>, IOrderedQueryable <AdjustStockSp> > order; // Order switch (Scroll.SortField) { case "SparePartName": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.SparePart.Name); } else { order = o => o.OrderBy(x => x.SparePart.Name); } break; case "Quantity": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.Quantity); } else { order = o => o.OrderBy(x => x.Quantity); } break; case "AdjustDate": if (Scroll.SortOrder == -1) { order = o => o.OrderByDescending(x => x.AdjustDate); } else { order = o => o.OrderBy(x => x.AdjustDate); } break; default: order = o => o.OrderByDescending(x => x.AdjustDate); break; } var QueryData = await this.repository.GetToListAsync( selector : selected => selected, // Selected predicate : predicate, // Where orderBy : order, // Order include : x => x.Include(z => z.SparePart), // Include skip : Scroll.Skip ?? 0, // Skip take : Scroll.Take ?? 50); // Take // Get TotalRow Scroll.TotalRow = await this.repository.GetLengthWithAsync(predicate : predicate); var mapDatas = new List <AdjustStockSpViewModel>(); foreach (var item in QueryData) { var MapItem = this.mapper.Map <AdjustStockSp, AdjustStockSpViewModel>(item); mapDatas.Add(MapItem); } return(new JsonResult(new ScrollDataViewModel <AdjustStockSpViewModel>(Scroll, mapDatas), this.DefaultJsonSettings)); }
public IHttpActionResult Guests(int id, GuestSearchViewModel vm) { var page = vm.Page.GetValueOrDefault(0); var pageSize = vm.PageSize.GetValueOrDefault(10); var skipRows = (page - 1) * pageSize; var ticketMailed = vm.IsMailed ?? false; var isWaiting = vm.IsWaiting ?? false; var isAttending = vm.IsAttending ?? false; var baseQuery = context.Guests.Where(e => e.EventId == id); var pred = PredicateBuilder.True <Guest>(); if (!string.IsNullOrWhiteSpace(vm.Address)) { pred = pred.And(p => p.Address.Contains(vm.Address)); } if (!string.IsNullOrWhiteSpace(vm.FinderNumber)) { pred = pred.And(p => p.FinderNumber.StartsWith(vm.FinderNumber)); } if (!string.IsNullOrWhiteSpace(vm.Name)) { pred = pred.And(p => p.Name.Contains(vm.Name)); } if (!string.IsNullOrWhiteSpace(vm.City)) { pred = pred.And(p => p.City.StartsWith(vm.City)); } if (!string.IsNullOrWhiteSpace(vm.State)) { pred = pred.And(p => p.State.Equals(vm.State)); } if (!string.IsNullOrWhiteSpace(vm.ZipCode)) { pred = pred.And(p => p.Zipcode.StartsWith(vm.ZipCode)); } if (!string.IsNullOrWhiteSpace(vm.Phone)) { pred = pred.And(p => p.Phone.Contains(vm.Phone)); } if (!string.IsNullOrWhiteSpace(vm.Email)) { pred = pred.And(p => p.Email.StartsWith(vm.Email)); } if (!string.IsNullOrWhiteSpace(vm.LookupId)) { pred = pred.And(p => p.LookupId.StartsWith(vm.LookupId)); } if (!string.IsNullOrWhiteSpace(vm.ConstituentType)) { pred = pred.And(p => p.ConstituentType.StartsWith(vm.ConstituentType)); } if (vm.TicketCount != null) { pred = pred.And(p => p.TicketCount == vm.TicketCount); } if (vm.IsMailed != null) { pred = pred.And(p => p.IsMailed == ticketMailed); } if (vm.IsWaiting != null) { pred = pred.And(p => p.IsWaiting == isWaiting); } if (vm.IsAttending != null) { pred = pred.And(p => p.IsAttending == isAttending); } var filteredQuery = baseQuery.Where(pred); var list = filteredQuery .Order(vm.OrderBy, vm.OrderDirection == "desc" ? SortDirection.Descending : SortDirection.Ascending) .Where(pred) .Skip(skipRows) .Take(pageSize) .ProjectTo <GuestViewModel>(); var totalCount = baseQuery.Count(); var filterCount = filteredQuery.Count(); var totalPages = (int)Math.Ceiling((decimal)filterCount / pageSize); vm.TotalCount = totalCount; vm.FilteredCount = filterCount; vm.TotalPages = totalPages; vm.Items = list.ToList(); return(Ok(vm)); }
protected override void OnInit() { targetMethod = typeof(MethodFinderTargetDummy).GetMethod("DoSomething"); builder = new PredicateBuilder(); }
private Expression <Func <Claim, bool> > buildPredicate() { int policyTypeID = 0; Expression <Func <Claim, bool> > predicate = null; string stateCode = null; // core search predicate = PredicateBuilder.True <CRM.Data.Entities.Claim>(); predicate = predicate.And(x => x.LeadPolicy.Leads.ClientID == clientID); // claims for this client only //predicate = predicate.And(x => (x.AdjusterID ?? 0) == 0); // no adjuster assigned predicate = predicate.And(x => x.IsActive == true); ///predicate = predicate.And(x => x.LeadPolicy.Lead.Status != 0); // active predicate = predicate.And(x => x.LeadPolicy.Leads.Status == 1); //OC 9/9/14 show only active, when deleting from all claims, was stll showing here // apply search filter if (!string.IsNullOrEmpty(txtClaimNumber.Text)) { predicate = predicate.And(x => x.AdjusterClaimNumber.Contains(txtClaimNumber.Text)); } if (!string.IsNullOrEmpty(txtCarrierName.Text)) { predicate = predicate.And(x => x.LeadPolicy.Carrier.CarrierName.Contains(txtCarrierName.Text)); } if (!string.IsNullOrEmpty(this.createDateFrom.Text) && !string.IsNullOrEmpty(this.createDateTo.Text)) { predicate = predicate.And(x => x.LeadPolicy.Leads.DateSubmitted >= createDateFrom.Date && x.LeadPolicy.Leads.DateSubmitted <= createDateTo.Date); } else if (!string.IsNullOrEmpty(this.createDateFrom.Text)) { predicate = predicate.And(x => x.LeadPolicy.Leads.DateSubmitted >= createDateFrom.Date); } if (!string.IsNullOrEmpty(this.lossDateFrom.Text) && !string.IsNullOrEmpty(this.lossDateTo.Text)) { predicate = predicate.And(x => x.LossDate >= lossDateFrom.Date && x.LossDate <= lossDateTo.Date); } else if (!string.IsNullOrEmpty(this.lossDateFrom.Text)) { predicate = predicate.And(x => x.LossDate >= lossDateFrom.Date); } if (ddlState.SelectedIndex > 0) { stateCode = ddlState.SelectedItem.Text.Trim(); predicate = predicate.And(x => x.LeadPolicy.Leads.StateName == stateCode); } if (ddlCity.SelectedIndex > 0) { predicate = predicate.And(x => x.LeadPolicy.Leads.CityName.Contains(ddlCity.SelectedItem.Text)); } if (!string.IsNullOrEmpty(txtZipCode.Text)) { predicate = predicate.And(x => x.LeadPolicy.Leads.Zip == txtZipCode.Text); } if (this.ucPolicyType1.SelectedIndex > 0) { policyTypeID = Convert.ToInt32(ucPolicyType1.SelectedValue); predicate = predicate.And(x => x.LeadPolicy.PolicyType == policyTypeID); } return(predicate); }
/// <summary> /// Get lab item category list of data /// </summary> /// <param name="request"></param> /// <returns></returns> public LabItemCategoryResponse GetListData(LabItemCategoryRequest request) { List <LabItemCategoryModel> lists = new List <LabItemCategoryModel>(); dynamic qry = null; var searchPredicate = PredicateBuilder.New <LabItemCategory>(true); // add default filter to show the active data only searchPredicate = searchPredicate.And(x => x.RowStatus == 0); if (!String.IsNullOrEmpty(request.SearchValue) && !String.IsNullOrWhiteSpace(request.SearchValue)) { searchPredicate = searchPredicate.And(p => p.Name.Contains(request.SearchValue)); } if (!(string.IsNullOrEmpty(request.SortColumn) && string.IsNullOrEmpty(request.SortColumnDir))) { if (request.SortColumnDir == "asc") { switch (request.SortColumn.ToLower()) { case "name": qry = _unitOfWork.LabItemCategoryRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.Name)); break; default: qry = _unitOfWork.LabItemCategoryRepository.Get(searchPredicate, orderBy: q => q.OrderBy(x => x.ID)); break; } } else { switch (request.SortColumn.ToLower()) { case "name": qry = _unitOfWork.LabItemCategoryRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.Name)); break; default: qry = _unitOfWork.LabItemCategoryRepository.Get(searchPredicate, orderBy: q => q.OrderByDescending(x => x.ID)); break; } } } else { qry = _unitOfWork.LabItemCategoryRepository.Get(searchPredicate, null); } foreach (var item in qry) { var prData = Mapper.Map <LabItemCategory, LabItemCategoryModel>(item); lists.Add(prData); } int totalRequest = lists.Count(); var data = lists.Skip(request.Skip).Take(request.PageSize).ToList(); var response = new LabItemCategoryResponse { Draw = request.Draw, RecordsFiltered = totalRequest, RecordsTotal = totalRequest, Data = data }; return(response); }
public IEnumerable <SlideShow> PagedSearchList(SortingPagingBuilder sortBuider, Paging page) { var expression = PredicateBuilder.True <SlideShow>(); return(FindAndSort(expression, sortBuider.Sorts, page)); }