コード例 #1
0
ファイル: NavController.cs プロジェクト: KaplinSergey/Auction
        public JsonResult Autocomplete(string term)
        {
            var lots = _lotService.GetAllForSaleLotEntities().Where(l => Regex.IsMatch(l.Name, term, RegexOptions.IgnoreCase))
                       .Select(l => new { id = l.Id, label = l.Name, value = l.Name });

            return(Json(lots.ToList(), JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
ファイル: LotController.cs プロジェクト: KaplinSergey/Auction
        public ViewResult Index(string category, string searchString, int page = 1)
        {
            IEnumerable <LotEntity>    lotsForSale = _lotService.GetAllForSaleLotEntities().Where(l => searchString == null || Regex.IsMatch(l.Name, searchString, RegexOptions.IgnoreCase));
            IEnumerable <LotViewModel> sortedLots  = lotsForSale.Where(l => category == null || l.Category.Name == category).Select(l => l.ToMvcLot()).OrderBy(l => l.StartDate)
                                                     .Reverse().Skip((page - 1) * pageSize).Take(pageSize);
            LotsListViewModel model = new LotsListViewModel
            {
                Lots       = sortedLots,
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = category == null?lotsForSale.Count() : lotsForSale.Where(l => l.Category.Name == category).Count()
                },
                CurrentCategory     = category,
                CurrentSearchString = searchString
            };

            return(View(model));
        }