コード例 #1
0
        //根据条件查询班车
        private Expression <Func <Bus_Line, bool> > SearchLineWhere(LineSearchViewModel lineSearchViewModel)
        {
            var predicate = WhereExtension.True <Bus_Line>();//初始化where表达式

            predicate = predicate.And(p => p.Code.Contains(lineSearchViewModel.Code));
            predicate = predicate.And(p => p.LineName.Contains(lineSearchViewModel.LineName));
            predicate = predicate.And(p => p.status.Contains(lineSearchViewModel.status));
            // predicate = predicate.And(p => p.Id==lineSearchViewModel.Id);

            return(predicate);
        }
コード例 #2
0
        /// <summary>
        /// 线路查询
        /// </summary>
        /// <param name="lineSearchViewModel"></param>
        /// <returns></returns>
        public List <LineSearchMiddlecs> Line_Search(LineSearchViewModel lineSearchViewModel)
        {
            List <Bus_Line> line_Infos = _IBusLineRepository.SearchInfoByLineWhere(lineSearchViewModel);

            List <LineSearchMiddlecs> lineSearches = new List <LineSearchMiddlecs>();

            foreach (var item in line_Infos)
            {
                var LineSearchMiddlecs = _IMapper.Map <Bus_Line, LineSearchMiddlecs>(item);
                lineSearches.Add(LineSearchMiddlecs);
            }
            return(lineSearches);
        }
コード例 #3
0
        public List <Bus_Line> SearchInfoByLineWhere(LineSearchViewModel lineSearchViewModel)
        {
            int SkipNum = lineSearchViewModel.pageViewModel.CurrentPageNum * lineSearchViewModel.pageViewModel.PageSize;

            //查询条件
            var predicate = SearchLineWhere(lineSearchViewModel);
            var result    = DbSet.Where(predicate).OrderBy(o => o.AddDate)
                            .Skip(SkipNum)
                            .Take(lineSearchViewModel.pageViewModel.PageSize)
                            .ToList();


            return(result);
        }
コード例 #4
0
        public ActionResult <LineSearchResModel> Manage_Line_Search(LineSearchViewModel lineSearchViewModel)
        {
            LineSearchResModel lineSearchResModel = new LineSearchResModel();
            var LineSearchResult = _lineService.Line_Search(lineSearchViewModel);

            // var TotalNum = _userService.User_Get_ALLNum();
            var TotalNum = _lineService.Line_Get_ALLNum(lineSearchViewModel);

            lineSearchResModel.bus_Line                   = LineSearchResult;
            lineSearchResModel.isSuccess                  = true;
            lineSearchResModel.baseViewModel.Message      = "查询成功";
            lineSearchResModel.baseViewModel.ResponseCode = 200;
            lineSearchResModel.TotalNum                   = TotalNum;
            _ILogger.Information("查询线路信息成功");
            return(Ok(lineSearchResModel));
        }
コード例 #5
0
ファイル: LineController.cs プロジェクト: KalinD/BDJ-exam
        public IActionResult Search(string?searchString)
        {
            LineSearchViewModel model;

            if (searchString != null)
            {
                model = new LineSearchViewModel()
                {
                    Lines = lineService.GetAll().Where(l => l.Destination.Contains(searchString) ||
                                                       l.Departure.Contains(searchString) ||
                                                       l.DepartureTime.ToString().Contains(searchString)).Select(l => new Line()
                    {
                        ArrivalTime   = l.ArrivalTime,
                        Date          = l.Date,
                        Departure     = l.Departure,
                        DepartureTime = l.DepartureTime,
                        Destination   = l.Destination,
                        Train         = trainService.GetById(l.TrainId),
                        Id            = l.Id,
                        TrainId       = l.TrainId
                    }).ToList()
                };
            }
            else
            {
                model = new LineSearchViewModel()
                {
                    Lines = lineService.GetAll().Select(l => new Line()
                    {
                        ArrivalTime   = l.ArrivalTime,
                        Date          = l.Date,
                        Departure     = l.Departure,
                        DepartureTime = l.DepartureTime,
                        Destination   = l.Destination,
                        Train         = trainService.GetById(l.TrainId),
                        Id            = l.Id,
                        TrainId       = l.TrainId
                    }).ToList()
                };
            }
            return(View(model));
        }
コード例 #6
0
        public IQueryable <Bus_Line> GetLineAll(LineSearchViewModel lineSearchViewModel)
        {
            var predicate = SearchLineWhere(lineSearchViewModel);

            return(DbSet.Where(predicate));
        }
コード例 #7
0
 /// <summary>
 /// 线路查询数量
 /// </summary>
 /// <param name="lineSearchViewModel"></param>
 /// <returns></returns>
 public int Line_Get_ALLNum(LineSearchViewModel lineSearchViewModel)
 {
     return(_IBusLineRepository.GetLineAll(lineSearchViewModel).Count());
 }