예제 #1
0
        public ActionResult RenderList(FilterInputDto input)
        {
            var query = _context.Vehicles.Where(x => x.DailyPrice > input.minPrice && x.DailyPrice <= input.maxPrice).AsQueryable();

            if (input.filterText != null)
            {
                query = query.Where(x => x.Brand.Contains(input.filterText) || x.Model.Contains(input.filterText));
            }
            if (input.orderByPrice)
            {
                query = query.OrderByDescending(x => x.DailyPrice);
            }
            else
            {
                query = query.OrderBy(x => x.DailyPrice);
            }
            List <VehicleDto> result = query.Select(x => new VehicleDto()
            {
                Id         = x.Id,
                Brand      = x.Brand,
                Model      = x.Model,
                Image      = x.Image,
                DailyPrice = x.DailyPrice,
                Year       = x.Year
            }).ToList();

            return(PartialView(new VehicleListViewModel()
            {
                Vehicles = result
            }));
        }
예제 #2
0
        /// <summary>
        /// 获取OperatorTree的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ListResultDto <OperatorTreeListDto> > GetOperatorTrees(FilterInputDto input)
        {
            var current = await AbpSession.CurrentAsync();

            var query = _operatortreeRepository.GetAll();

            query = query.WhereIf(!input.Filter.IsNullOrWhiteSpace(), c => c.TreeCode.Contains(input.Filter))
                    .WhereIf(!current.TreeCode.IsNullOrWhiteSpace(),
                             c => c.TreeCode.Contains(current.TreeCode));
            var operatortrees = await query
                                .ToListAsync();

            var operatortreeListDtos = operatortrees.MapTo <List <OperatorTreeListDto> >();

            if (!current.IsAdmin && !current.TreeCode.IsNullOrWhiteSpace())
            {
                var node = operatortreeListDtos.FirstOrDefault(c => c.TreeCode == current.TreeCode);
                if (node != null)
                {
                    node.ParentId = null;
                }
            }
            return(new ListResultDto <OperatorTreeListDto>(
                       operatortreeListDtos
                       ));
        }
예제 #3
0
 public VehicleListViewModel()
 {
     Vehicles       = new List <VehicleDto>();
     FilterInputDto = new FilterInputDto();
 }