private GoodsListViewModel GetGoodVM(string category, string manufacturer, int page = 1, decimal from = 0, decimal to = decimal.MaxValue) { var predicate = PredicateBuilder.New <Good>(); var pred = PredicateBuilder.New <Good>(); pred.And(i => category == null || i.Category.CategoryName.Contains(category)); pred.And(i => manufacturer == null || i.Manufacturer.ManufacturerName.Contains(manufacturer)); pred.And(i => from == default || i.Price >= from); pred.And(i => from == decimal.MaxValue || i.Price <= to); predicate.Extend(pred, PredicateOperator.Or); var goods = _goodsRepo.Get(predicate).ToList(); var count = goods.Count(); GoodsListViewModel goodVM = new GoodsListViewModel { Goods = goods .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = count }, CurrentCategory = category, CurrentManufacturer = manufacturer }; return(goodVM); }
public ViewResult GetListOfGoods() { ViewBag.PageTitle = "TEATIME - Главная"; var obj = new GoodsListViewModel(); obj.AllGoods = _allGoods.Goods; obj.currentCategory = "Чай"; return(View(obj)); }
public ActionResult Index() { // View Model is a combination of multiple models combined together and passed to the view. // ViewModel should be built inside of the parent method. var viewModel = new GoodsListViewModel { GoodsList = this.goodsList, GoodsListRating = this.goodsListRatings }; return(View(viewModel)); }
public async Task <ActionResult> List(long?goodsTypeId, long?goodsSecondTypeId, string keyword, DateTime?startTime, DateTime?endTime, int pageIndex = 1) { var result = await goodsService.GetModelListAsync(null, goodsTypeId, goodsSecondTypeId, keyword, startTime, endTime, pageIndex, pageSize); GoodsListViewModel model = new GoodsListViewModel(); model.Goods = result.Goods; model.PageCount = result.PageCount; model.GoodsTypes = (await goodsTypeService.GetModelListAsync(null, null, null, 1, 100)).GoodsTypes; model.GoodsAreas = (await goodsAreaService.GetModelListAsync(null, null, null, 1, 100)).GoodsAreas; return(Json(new AjaxResult { Status = 1, Data = model })); }
public ViewResult List(string category) { string _category = category; IEnumerable <Goods> goods = null; string currCategory = ""; if (string.IsNullOrEmpty(category)) { goods = _allGoods.Goods.OrderBy(i => i.id); } else { if (string.Equals("Chairs", category, StringComparison.OrdinalIgnoreCase)) { goods = _allGoods.Goods.Where(i => i.Category.categoryName.Equals("Chairs")).OrderBy(i => i.id); } else if (string.Equals("Beds", category, StringComparison.OrdinalIgnoreCase)) { goods = _allGoods.Goods.Where(i => i.Category.categoryName.Equals("Beds")).OrderBy(i => i.id); } else if (string.Equals("Accesoires", category, StringComparison.OrdinalIgnoreCase)) { goods = _allGoods.Goods.Where(i => i.Category.categoryName.Equals("Accesoires")).OrderBy(i => i.id); } else if (string.Equals("Furniture", category, StringComparison.OrdinalIgnoreCase)) { goods = _allGoods.Goods.Where(i => i.Category.categoryName.Equals("Furniture")).OrderBy(i => i.id); } else if (string.Equals("Bathroom", category, StringComparison.OrdinalIgnoreCase)) { goods = _allGoods.Goods.Where(i => i.Category.categoryName.Equals("Bathroom")).OrderBy(i => i.id); } else if (string.Equals("Tables", category, StringComparison.OrdinalIgnoreCase)) { goods = _allGoods.Goods.Where(i => i.Category.categoryName.Equals("Tables")).OrderBy(i => i.id); } currCategory = _category; } var goodsObj = new GoodsListViewModel { allGoods = goods, currCategory = currCategory }; ViewBag.Title = "Amado - Furniture Ecommerce Shop"; return(View(goodsObj)); }
// GET: /<controller>/ public async Task <ActionResult> Index() { var _goodses = (await _goodsAppService.GetAll(new PagedResultRequestDto { MaxResultCount = MaxNum })).Items; //Paging not implemented yet //GoodsDto cuGoods = goods.FirstOrDefault(); var model = new GoodsListViewModel { //Goods = cuGoods, Goodses = _goodses }; return(View(model)); }
public async Task <ViewResult> GoodsCards(SearchGoods search, int page = 1) { ICollection <GoodsModel> goods = await this._repository.GetGoodsForOnePageAsync(search, pageSize, page); PagingInfo pageInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = pageSize, TotalItems = await _repository.GetCountGoodsAsync(search) }; GoodsListViewModel model = new GoodsListViewModel() { Goods = goods, PagingInfo = pageInfo, Search = search }; return(View(model)); }
public ViewResult List(string category, string tnpa, int page = 1) { GoodsListViewModel model = new GoodsListViewModel { Goods = repository.Goods .Where(p => category == null || p.Category == category) .OrderBy(good => good.GoodId) .Skip((page - 1) * pageSize) .Take(pageSize), GoodPagingInfo = new GoodPagingInfo { CurrentPage = page, ItemsPerPage = pageSize, TotalItems = category == null?repository.Goods.Count() : repository.Goods.Where(good => good.Category == category).Count() }, CurrentCategory = category }; return(View(model)); }
public ActionResult List(string category, string manufacturer, int page = 1) { GoodsListViewModel model = new GoodsListViewModel { Goods = _goodsRepo.GetAll() .Where(p => category == null || p.Category.CategoryName == category) .Where(p => manufacturer == null || p.Manufacturer.ManufacturerName == manufacturer) .OrderBy(p => p.GoodId) .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = GetItemsCount(category, manufacturer) }, CurrentCategory = category, CurrentManufacturer = manufacturer }; return(View(model)); }
public ActionResult Index(string category) { IQueryable <Good> goods = db.Goods.Include(p => p.Category); if (!String.IsNullOrEmpty(category) && !category.Equals("Все")) { goods = goods.Where(p => p.Category.Name == category); } GoodsListViewModel listView = new GoodsListViewModel { Goods = goods.ToList(), Categories = new SelectList(new List <string>() { "Все", "Гелиевые", "Фигуры", "Композиции", "Оформление" }) }; return(View(listView)); }
public ActionResult Goods(GoodsListViewModel goodVM) { var newGoodsVM = GetGoodVM(goodVM.CurrentCategory, goodVM.CurrentManufacturer, goodVM.PagingInfo.CurrentPage); return(View(newGoodsVM)); }
public ViewResult Goods(string category, string manufacturer, int page = 1, decimal from = 0, decimal to = decimal.MaxValue) // старый фильтр не пашет { GoodsListViewModel newGoodVM = GetGoodVM(category, manufacturer, page, from, to); return(View(newGoodVM)); }
public async Task <IActionResult> Index(string category, string sort, string name, int?categories1, double price_min = 1, double price_max = 100000, int page = 1) { int pageSize = 3; IQueryable <Goods> goods = unitOfWork.Goods.GetGoods1.Include(i => i.Category); if (string.IsNullOrEmpty(category)) { goods = unitOfWork.Goods.GetGoods1; } else { if (string.Equals("Відеокарти", category, StringComparison.OrdinalIgnoreCase)) { goods = unitOfWork.Goods.GetGoods1.Where(i => i.Category.id == 2); } if (string.Equals("Процесори", category, StringComparison.OrdinalIgnoreCase)) { goods = unitOfWork.Goods.GetGoods1.Where(i => i.Category.id == 3); } if (sort != null) { Sort(goods, sort); } } if (categories1 != null && categories1 != 0) { goods = goods.Where(p => p.id_category == categories1); } if (!String.IsNullOrEmpty(name)) { goods = goods.Where(p => p.name.Contains(name)); } goods = goods.Where(i => i.price >= price_min && i.price <= price_max); List <Category> categories = unitOfWork.Category.GetCategories.ToList(); categories.Insert(0, new Category { Name = "Все", id = 0 }); //IEnumerable<Goods> goods1 = unitOfWork.Goods.GetGoods.ToList().Where(i => i.price >= price_min && i.price <= price_max); var count = await goods.CountAsync(); var items = await goods.Skip((page - 1) *pageSize).Take(pageSize).ToListAsync(); PageViewModel pageViewModel = new PageViewModel(count, page, pageSize); var goodsObj = new GoodsListViewModel { AllGoods = items.AsQueryable(), categories = category, PageViewModel = pageViewModel, Name = name, categories1 = new SelectList(categories, "id", "Name"), cat = categories1, price_min = price_min, price_max = price_max }; if (category == "Процесори") { ViewBag.Title = "Процесори"; } else if (category == "Відеокарти") { ViewBag.Title = "Відеокарти"; } else { ViewBag.Title = "Головна"; } //ViewData["PriceSort"] = sort; return(View(goodsObj)); }