//根据条件查询用户
        private Expression <Func <VolunteerActivity, bool> > SearchVAWhere(VolunteerActivitySearchViewModel VSearchViewModel)
        {
            var predicate = WhereExtension.True <VolunteerActivity>();//初始化where表达式

            if (!String.IsNullOrEmpty(VSearchViewModel.ID))
            {
                predicate = predicate.And(p => p.ID.Contains(VSearchViewModel.ID));
            }
            if (!String.IsNullOrEmpty(VSearchViewModel.Title))
            {
                predicate = predicate.And(p => p.Title.Contains(VSearchViewModel.Title));
            }
            if (!String.IsNullOrEmpty(VSearchViewModel.CommunityID))
            {
                predicate = predicate.And(p => p.CommunityID.Contains(VSearchViewModel.CommunityID));
            }
            if (!String.IsNullOrEmpty(VSearchViewModel.Address))
            {
                predicate = predicate.And(p => p.Address.Contains(VSearchViewModel.Address));
            }
            if (!String.IsNullOrEmpty(VSearchViewModel.TypeIDs))
            {
                predicate = predicate.And(p => p.TypeIDs.Contains(VSearchViewModel.TypeIDs));
            }

            return(predicate);
        }
Esempio n. 2
0
        public List <VolunteerActivityMidModel> SearchList(VolunteerActivitySearchViewModel searchViewModel)
        {
            List <VolunteerActivity>         model           = _volunteerActivityRepository.SearchInfoByWhere(searchViewModel);
            List <VolunteerActivityMidModel> searchModelList = new List <VolunteerActivityMidModel>();

            foreach (var item in model)
            {
                var searchModel = _IMapper.Map <VolunteerActivity, VolunteerActivityMidModel>(item);
                searchModelList.Add(searchModel);
            }
            return(searchModelList);
        }
        //根据条件查询

        public List <VolunteerActivity> SearchInfoByWhere(VolunteerActivitySearchViewModel VSearchViewModel)
        {
            int SkipNum = VSearchViewModel.pageViewModel.CurrentPageNum * VSearchViewModel.pageViewModel.PageSize;

            //查询条件
            var predicate = SearchVolunteerWhere(VSearchViewModel);

            var result = DbSet.Where(predicate)
                         .Skip(SkipNum)
                         .Take(VSearchViewModel.pageViewModel.PageSize)
                         .OrderBy(o => o.CreateDate).ToList();


            return(result);
        }
        //根据条件查询用户
        private Expression <Func <VolunteerActivity, bool> > SearchVolunteerWhere(VolunteerActivitySearchViewModel VSearchViewModel)
        {
            var predicate = WhereExtension.True <VolunteerActivity>();//初始化where表达式

            predicate = predicate.And(p => p.Status.Equals("1"));

            if (VSearchViewModel.Title != "")
            {
                predicate = predicate.And(p => p.Title.Contains(VSearchViewModel.Title));
            }
            if (VSearchViewModel.Content != "")
            {
                predicate = predicate.And(p => p.Content.Contains(VSearchViewModel.Content));
            }
            if (VSearchViewModel.Type != "")
            {
                predicate = predicate.And(p => p.Type.Contains(VSearchViewModel.Type));
            }
            if (VSearchViewModel.CommunityID != "")
            {
                predicate = predicate.And(p => p.CommunityID.Equals(VSearchViewModel.CommunityID));
            }
            return(predicate);
        }
Esempio n. 5
0
        public int GetAllCount(VolunteerActivitySearchViewModel searchModel)
        {
            int result = _volunteerActivityRepository.GetVolunteerAll(searchModel).Count();

            return(result);
        }
        public IQueryable <VolunteerActivity> GetAll(VolunteerActivitySearchViewModel VSearchViewModel)
        {
            var predicate = SearchVolunteerWhere(VSearchViewModel);

            return(DbSet.Where(predicate));
        }
Esempio n. 7
0
        public ActionResult <VolunteerActivitySearchResModel> Manage_VolunteerActivity_Search(VolunteerActivitySearchViewModel searchModel)
        {
            VolunteerActivitySearchResModel returnModel = new VolunteerActivitySearchResModel();
            var midModel = _volunteerActivityService.SearchList(searchModel);
            var totalNum = _volunteerActivityService.GetAllCount(searchModel);

            returnModel.IsSuccess                  = true;
            returnModel.TotalNum                   = totalNum;
            returnModel.Activity                   = midModel;
            returnModel.baseViewModel.Message      = "查询成功";
            returnModel.baseViewModel.ResponseCode = 200;
            //_ILogger.Information("查询活动信息成功");
            return(Ok(returnModel));
        }