/// <summary> /// 查询楼宇信息 /// </summary> /// <param name="buildingSearchViewModel"></param> /// <returns></returns> public List <BuildingSearchMiddleViewModel> Building_Search(BuildingSearchViewModel buildingSearchViewModel) { var BuildingSearchResult = _buildingRepository.BuildingSerachByWhere(buildingSearchViewModel).ToList(); var BuildingSearchResultModel = _IMapper.Map <List <Building>, List <BuildingSearchMiddleViewModel> >(BuildingSearchResult); return(BuildingSearchResultModel); }
public int BuildingSerachByWhereCount(BuildingSearchViewModel buildingSearchViewModel) { var predicate = SearchBuildingWhere(buildingSearchViewModel); var result = DbSet.Where(predicate).ToList().Count(); return(result); }
//根据检索条件 统计有多少栋楼 public int BuildingSerachByWhereBuildingNoCount(BuildingSearchViewModel buildingSearchViewModel) { var predicate = SearchBuildingWhere(buildingSearchViewModel); var result = DbSet.Where(predicate).ToList() .GroupBy(a => a.BuildingNo).Select(a => a.First()).ToList() .Count(); return(result); }
/// <summary> /// 查询住户数 /// </summary> /// <param name="buildingSearchViewModel"></param> /// <returns></returns> public int HouseCountByWhere(BuildingSearchViewModel buildingSearchViewModel) { //查询条件 var predicate = SearchHouseCountWhere(buildingSearchViewModel); var result = DbSet .Where(predicate).ToList().Count(); return(result); }
public IActionResult SearchResults(BuildingSearchViewModel model) { foreach (var modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { var x = error; } } var filters = new List <Tuple <string, object> >(); foreach (var property in model.GetType().GetProperties()) { var value = property.GetValue(model); if (value == null) { continue; } if (property.PropertyType == typeof(decimal?)) { if (property.Name.EndsWith("Low")) { filters.Add(new Tuple <string, object>($"{property.Name.Substring(0, property.Name.Length - 3)} > {{0}}", $"{(decimal)value}")); } else { filters.Add(new Tuple <string, object>($"{property.Name.Substring(0, property.Name.Length - 4)} < {{0}}", $"{(decimal)value}")); } } if (property.PropertyType == typeof(DateTime?)) { if (property.Name.EndsWith("Start")) { filters.Add(new Tuple <string, object>($"{property.Name.Substring(0, property.Name.Length - 5)} > {{0}}", $"{(DateTime)value}")); } else { filters.Add(new Tuple <string, object>($"{property.Name.Substring(0, property.Name.Length - 3)} < {{0}}", $"{(DateTime)value}")); } } if (property.PropertyType == typeof(string) && !string.IsNullOrEmpty(value.ToString().Trim())) { filters.Add(new Tuple <string, object>($"{property.Name} LIKE {{0}}", $"%{value.ToString()}%")); } } var buildings = _buildingRepository.GetBuildings(filters); return(View("Index", buildings)); }
public List <Building> BuildingSerachByWhere(BuildingSearchViewModel buildingSearchViewModel) { int SkipNum = buildingSearchViewModel.pageViewModel.CurrentPageNum * buildingSearchViewModel.pageViewModel.PageSize; //查询条件 var predicate = SearchBuildingWhere(buildingSearchViewModel); var result = DbSet.Where(predicate).ToList() .Skip(SkipNum) .Take(buildingSearchViewModel.pageViewModel.PageSize) .OrderBy(a => a.AddTime).ToList(); return(result); }
private Expression <Func <HouseInfo, bool> > SearchHouseCountWhere(BuildingSearchViewModel buildingSearchViewModel) { var predicate = WhereExtension.True <HouseInfo>();//初始化where表达式 if (buildingSearchViewModel.Name != "") { predicate = predicate.And(p => p.Area.Equals(buildingSearchViewModel.Name)); } return(predicate); }
public IActionResult GetBuildingSearch([FromQuery] BuildingSearchViewModel building) { try { return(Ok(manager.GetBuildingSearch(building))); } catch (Exception ex) { Exception innerException = ex; while (innerException != null) { Log.Error(innerException.Message); Log.Error(innerException.StackTrace); innerException = ex.InnerException; } return(BadRequest(ex.Message)); } }
//根据条件查询部门 private Expression <Func <Building, bool> > SearchBuildingWhere(BuildingSearchViewModel buildingSearchViewModel) { var predicate = WhereExtension.True <Building>();//初始化where表达式 //predicate = predicate.And(p => p.Name.ToString().Contains(buildingSearchViewModel.Name.ToString())); if (buildingSearchViewModel.Name != "") { predicate = predicate.And(p => p.Name.Contains(buildingSearchViewModel.Name)); } if (buildingSearchViewModel.Id != null) { predicate = predicate.And(p => p.Id.Equals(buildingSearchViewModel.Id)); } predicate = predicate.And(p => p.Status == "1"); return(predicate); }
public IEnumerable <BuildingOverviewItemViewModel> GetBuildingSearch(BuildingSearchViewModel buildingSearch) { using CampFinderDbContext context = dbContextFactory.CreateDbContext(); IQueryable <Building> buildings = context.Buildings .Include(t => t.Reviews) .Include(t => t.Place); if (buildingSearch != null) { buildings = GetSearch(buildings, buildingSearch); if (buildingSearch.Beds) { buildings = buildings.Where(b => b.Beds); } if (buildingSearch.KitchenGear) { buildings = buildings.Where(b => b.KitchenGear); } } return(buildings.Select(b => mapper.Map <BuildingOverviewItemViewModel>(b)).ToList()); }
public ActionResult <BuildingSearchResViewModel> Manage_OpinionInfo_Search(BuildingSearchViewModel buildingSearchViewModel) { var SearchResult = _buildingService.Building_Search(buildingSearchViewModel); int total = _buildingService.Building_SearchCount(buildingSearchViewModel); int buildingNoCount = _buildingService.Building_SearchBuildingNoCount(buildingSearchViewModel); int unitNoCount = _buildingService.Building_SearchUnitNoCount(buildingSearchViewModel); int houseNoCount = _houseInfoService.HouseCountSearch(buildingSearchViewModel); var Actionresult = _buildingFactory.GetBuildingSearchResViewModel(); Actionresult.baseViewModel.IsSuccess = true; Actionresult.Data = SearchResult; Actionresult.TotalCount = total; Actionresult.BuildingNoCount = buildingNoCount; Actionresult.UnitNoCount = unitNoCount; Actionresult.HouseNoCount = houseNoCount; Actionresult.baseViewModel.Message = "查询信息成功"; Actionresult.baseViewModel.ResponseCode = 200; _ILogger.Information("查询信息成功"); return(Ok(Actionresult)); }
/// <summary> /// 根据小区名查 住户数量 /// </summary> /// <param name="buildingSearchViewModel"></param> /// <returns></returns> public int HouseCountSearch(BuildingSearchViewModel buildingSearchViewModel) { return(_houseInfoRepository.HouseCountByWhere(buildingSearchViewModel)); }
//单元数 public int Building_SearchUnitNoCount(BuildingSearchViewModel buildingSearchViewModel) { return(_buildingRepository.BuildingSerachByWhereUnitNoCount(buildingSearchViewModel)); }