Exemplo n.º 1
0
        public ActionResult AdResults(string categoryName,string subcategory,int Id, int page = 1)
        {
            //int id = 0;
            int pageSize = 10;

            //id = _Repository.GetCategoryId(categoryName);
            //if (id == 0)
            SubCategory sc = _Repository.GetSubCategorybyId(Id);
               var advertList = new NinjaLista.Views.Models.AdvertListModel();
               advertList.subcatlist = _Repository.GetPopularCategoriesList();
               advertList.Id = sc.CategoryId;
               //advertList.type = "";
               var adverts = _Repository.GetAllPostAds(Id);
            var advertsTotalCount = adverts.Count;
            advertList.adverts = (adverts).Skip((page - 1) * pageSize).Take(pageSize).ToList();

            advertList.CurrentCategory = sc.SubCategoryName;
            advertList.PagingInfo = new NinjaLista.Views.Models.PagingInfo
            {
                CurrentPage = page,
                ItemsPerPage = pageSize,
                TotalItems = advertsTotalCount,
                CurrentCategory = sc.CategoryName,
                SubCurrentCategory = sc.SubCategoryName,
                type = ""// categoryName
            };
            return View(advertList);
        }
Exemplo n.º 2
0
        public ActionResult SearchResults(string keyword, int page = 1)
        {
            //AdvertListModel vm = new AdvertListModel();

            //int id = 0;
            int pageSize = 10;
            keyword = keyword.Replace("_$_","").Replace("-"," ");
            //id = _Repository.GetCategoryId(categoryName);
            //if (id == 0)
            //SubCategory sc = _Repository.GetSubCategorybyId(Id);
            var advertList = new NinjaLista.Views.Models.AdvertListModel();
            advertList.subcatlist = _Repository.GetPopularCategoriesList();
            //advertList.Id = sc.CategoryId;
            //advertList.type = "";
            var adverts = _Repository.GetSearchResults(keyword);
            var advertsTotalCount = adverts.Count;
            TempData["keyword"] = keyword   ;
            advertList.adverts = (adverts).Skip((page - 1) * pageSize).Take(pageSize).ToList();

            //advertList.CurrentCategory = sc.SubCategoryName;
            advertList.PagingInfo = new NinjaLista.Views.Models.PagingInfo
            {
                CurrentPage = page,
                ItemsPerPage = pageSize,
                TotalItems = advertsTotalCount,
                CurrentCategory = keyword == "" ?"_$_":keyword,//"search",
                //SubCurrentCategory = keyword,
                type = "search"// categoryName
            };
            return View(advertList);
        }