public IActionResult SearchBus(BusSearchViewModel model)
        {
            if (ModelState.IsValid)
            {
                var busFound      = this._busRepo.GetBusesByCity(model.SelectedSourceCity, model.SelectedDestinationCity);
                var busFoundModel = new BusFoundViewModel();
                busFoundModel.busFound        = busFound;
                busFoundModel.dateToTravel    = model.DateToTravel;
                busFoundModel.SourceCity      = model.SelectedSourceCity;
                busFoundModel.DestinationCity = model.SelectedDestinationCity;

                /*if(busFoundModel.SourceCity.Equals(busFoundModel.DestinationCity)
                 *  {
                 *  ErrorMessage = "Source City and Destination city cannot be same";
                 * }
                 * else
                 * {*/
                return(View("BusFound", busFoundModel));
                //}
            }
            else
            {
                return(View(model));
            }
        }
示例#2
0
        //根据条件查询班车
        private Expression <Func <Bus_Info, bool> > SearchBusWhere(BusSearchViewModel busSearchViewModel)
        {
            var predicate = WhereExtension.True <Bus_Info>();//初始化where表达式

            predicate = predicate.And(p => p.Code.Contains(busSearchViewModel.Code));
            predicate = predicate.And(p => p.DriverName.Contains(busSearchViewModel.DriverName));
            predicate = predicate.And(p => p.CarPlate.Contains(busSearchViewModel.CarPlate));
            predicate = predicate.And(p => p.SeatNum.Contains(busSearchViewModel.SeatNum));
            predicate = predicate.And(p => p.status.Contains(busSearchViewModel.status));
            return(predicate);
        }
示例#3
0
        public List <BusSearchMiddlecs> Bus_Search(BusSearchViewModel busSearchViewModel)
        {
            List <Bus_Info> bus_Infos = _IBusInfoRepository.SearchInfoByBusWhere(busSearchViewModel);

            List <BusSearchMiddlecs> busSearches = new List <BusSearchMiddlecs>();

            foreach (var item in bus_Infos)
            {
                var BusSearchMiddlecs = _IMapper.Map <Bus_Info, BusSearchMiddlecs>(item);
                busSearches.Add(BusSearchMiddlecs);
            }
            return(busSearches);
        }
        public ViewResult SearchBus()
        {
            var sourceCity      = this._busRepo.getSourceCity();
            var destinationCity = this._busRepo.getDestinationCity();
            var busSearch       = new BusSearchViewModel()
            {
                SourceCity      = sourceCity,
                DestinationCity = destinationCity,
            };


            Console.WriteLine(sourceCity);
            return(View(busSearch));
        }
示例#5
0
        //根据条件查询

        public List <Bus_Info> SearchInfoByBusWhere(BusSearchViewModel busSearchViewModel)
        {
            int SkipNum = busSearchViewModel.pageViewModel.CurrentPageNum * busSearchViewModel.pageViewModel.PageSize;

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


            return(result);
        }
示例#6
0
        public ActionResult <BusSearchResModel> Manage_Bus_Search(BusSearchViewModel busSearchViewModel)
        {
            BusSearchResModel busSearchResModel = new BusSearchResModel();
            var BusSearchResult = _busService.Bus_Search(busSearchViewModel);

            // var TotalNum = _userService.User_Get_ALLNum();
            var TotalNum = _busService.Bus_Get_ALLNum(busSearchViewModel);

            busSearchResModel.bus_Infos                  = BusSearchResult;
            busSearchResModel.isSuccess                  = true;
            busSearchResModel.baseViewModel.Message      = "查询成功";
            busSearchResModel.baseViewModel.ResponseCode = 200;
            busSearchResModel.TotalNum = TotalNum;
            _ILogger.Information("查询班车信息成功");
            return(Ok(busSearchResModel));
        }
示例#7
0
 /// <summary>
 /// 查询班车数量
 /// </summary>
 /// <param name="busSearchViewModel"></param>
 /// <returns></returns>
 public int Bus_Get_ALLNum(BusSearchViewModel busSearchViewModel)
 {
     return(_IBusInfoRepository.GetBusAll(busSearchViewModel).Count());
 }
示例#8
0
        /// <summary>
        /// 查班车数量
        /// </summary>
        /// <param name="busSearchViewModel"></param>
        /// <returns></returns>
        public IQueryable <Bus_Info> GetBusAll(BusSearchViewModel busSearchViewModel)
        {
            var predicate = SearchBusWhere(busSearchViewModel);

            return(DbSet.Where(predicate));
        }