public ProductList() { StyleManager.ApplicationTheme = new Windows8TouchTheme(); InitializeComponent(); var productListViewModel = new ProductListViewModel(); productListViewModel.CloseWindow += Close; DataContext = productListViewModel; }
public ActionResult List([DefaultValue(1001)]int categoryId) { var model = new ProductListViewModel { CategoryId = categoryId, Products = _productService.GetAll(categoryId) }; return View(model); }
public MainViewModel(ProductListViewModel productListModel, InventoryViewModel newInventoryModel, NewProductViewModel newProductModel) { NewInventoryModel = newInventoryModel; NewProductModel = newProductModel; ProductListModel = productListModel; Languages = new ObservableCollection<string>() {"en", "zh-Hans", "fr-FR"}; LocalizeDictionary.Instance.SetCurrentThreadCulture = true; LocalizeDictionary.Instance.SetCultureCommand.Execute("en"); SelectedLanguage = "en"; }
// GET: Product public ActionResult Index() { var vm = new ProductListViewModel(); vm.DisplayName = Strings.ProductViewModel_DisplayName; vm.Items = Service.GetAllProducts().ToList(); vm.SelectedItem = vm.Items.FirstOrDefault(); // Finish Action return View(vm); }
// // Get /Product/List/ public ViewResult List(string category, int page = 1) { ProductListViewModel viewModel = new ProductListViewModel { Products = _repo.Products.Where(p => string.IsNullOrEmpty(category) || p.Category == category).OrderBy(p => p.ProductID).Skip((page - 1) * PageSize).Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = string.IsNullOrEmpty(category) ? _repo.Products.Count() : _repo.Products.Where(p => p.Category == category).Count() }, CurrentCategory = category }; return View(viewModel); }
public void TestPagination(CategoryEnum categoryEnum) { // ACT Mock <IStoreRepository> storeRepoMock = new Mock <IStoreRepository>(); storeRepoMock.Setup(m => m.Products) .Returns((new Product[] { new Product { Name = "Test1", Price = 99.90m }, new Product { Name = "Test2", Price = 98.90m }, new Product { Name = "Test3", Price = 97.90m }, new Product { Name = "Test4", Price = 96.90m }, new Product { Name = "Test5", Price = 95.90m }, new Product { Name = "Test6", Price = 94.90m } }).AsQueryable <Product>()); StoreController storeController = new StoreController(storeRepoMock.Object, new Cart()); storeController.PageSize = 4; // ARRANGE ProductListViewModel productListView = ((ViewResult)storeController.Index(categoryEnum.ToString(), 2)) .ViewData.Model as ProductListViewModel; // Assert Product[] products = productListView.Products.ToArray(); Assert.That(products.Length == 2); Assert.AreEqual(products[0].Name, "Test5"); Assert.AreEqual(products[0].Price, 95.90m); Assert.AreEqual(products[1].Name, "Test6"); Assert.AreEqual(products[1].Price, 94.90m); }
public ActionResult Index(string category = null, int page = 1) { IEnumerable <ProductViewModel> products = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:24554/api/"); var responseTask = client.GetAsync("product"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <IEnumerable <ProductViewModel> >(); readTask.Wait(); products = readTask.Result; } else { products = Enumerable.Empty <ProductViewModel>(); } } ProductListViewModel listProduct = new ProductListViewModel { Products = products .Where(p => category == null || p.ThuongHieu.TenThuongHieu == category) .OrderBy(p => p.SuaID) .Skip((page - 1) * pageSize) .Take(pageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = pageSize, TotalItems = category == null? products.Count() : products.Where(e => e.ThuongHieu.TenThuongHieu == category).Count() }, CurrentCategory = category }; return(View(listProduct)); }
public async Task <IActionResult> ProductDetailBlank(int ProductId, int MemberLevelId = -1) { // 2-1.系統在Get Controller Action【Mall/GetProductDetail】呼叫ViewComponent【ProductDetail】並傳送2傳送之商品代碼。 // 3.系統在ViewComponent【ProductDetail】讀取商品基本資料。 ProductListViewModel PLVM = await IPRR.GetProduct(ProductId); // 4.系統在ViewComponent【ProductDetail】讀取商品尺寸資料。 List <ProductSizeViewModel> lstPSVM = IPRR.GetProductSizeSync(ProductId); // 5.系統在ViewComponent【ProductDetail】讀取商品顏色資料。 List <ProductColorViewModel> lstPCVM = IPRR.GetProductColorSync(ProductId); ProductStockListViewModel PSLVM; if (lstPSVM == null || lstPCVM == null || lstPSVM.Count == 0 || lstPCVM.Count == 0) { PSLVM = null; } else { // 6.系統在ViewComponent【ProductDetail】讀取商品第1個尺寸第1個顏色的庫存資料。 PSLVM = await IPRR.GetProductStock(ProductId, lstPSVM[0].ProducSizeId, lstPCVM[0].ProductColorId); if (PSLVM == null) { // 6-1a.系統判斷6傳回null。 // 6-1a-1.系統New ProductStockListViewModel {},將Stock設為0。 PSLVM = new ProductStockListViewModel { ProductId = ProductId, ProducSizeId = lstPSVM[0].ProducSizeId, ProductColorId = lstPCVM[0].ProductColorId, Stock = 0 }; // 6-1a-2.回7。 } } // 6-0.系統在ViewComponent【ProductDetail】讀取讀取商品圖示清單: List <ProductImageListViewModel> lstPIVM = await IPRR.GetProductImageList(ProductId, 0, 1000); // 7.系統回傳View(new ProductDetailMallViewModel { Product=3讀取值, ProductSize=4傳回值, ProductColor=5傳回值, ProductStock=6傳回值 })。 //int? MemberLevelId = -1; //if (HttpContext.Session.GetInt32("MemberLevelId") != null) // MemberLevelId = HttpContext.Session.GetInt32("MemberLevelId"); //else // MemberLevelId = -1; return(View(new ProductDetailMallViewModel { Product = PLVM, ProductSize = lstPSVM, ProductColor = lstPCVM, ProductStock = PSLVM, ProductImage = lstPIVM, MemberLevelId = MemberLevelId })); }
public async Task <IActionResult> Index(string search) { List <ProductListViewModel> model = new List <ProductListViewModel>(); var dbData = await _unitOfWork.Repository <Product>().GetAllIncludeAsync(b => b.Brand, c => c.Category, u => u.Unit, com => com.ProductCommentses, pi => pi.ProductImages, ps => ps.ProductStocks); if (!String.IsNullOrEmpty(search)) { dbData = dbData.Where(x => x.Name.ToLower().Contains(search.ToLower()) || x.Code.ToLower().Contains(search.ToLower()) || x.Tag.ToLower().Contains(search.ToLower()) ).ToList(); } foreach (var b in dbData) { ProductListViewModel product = new ProductListViewModel { Id = b.Id, Name = b.Name, Code = b.Code, Tag = b.Tag, CategoryId = b.CategoryId, BrandId = b.BrandId, UnitId = b.UnitId, Description = b.Description, Price = b.Price, BrandName = b.Brand.Name, CategoryName = b.Category?.Name, UnitName = b.Unit.Name, Discount = b.Discount, FinalPrice = (b.Price - ((b.Price * b.Discount) / 100)), ProductComments = b.ProductCommentses.Count, TotalImage = b.ProductImages.Count }; var prdctStocks = b.ProductStocks.FirstOrDefault(); product.ProductStocks = prdctStocks != null ? product.ProductStocks = prdctStocks.InQuantity - prdctStocks.OutQuantity : product.ProductStocks = 0; model.Add(product); } return(View(model)); }
/** * handles GET requests to the List page, optionally with 'category' parameter from hmtl option element * 'category' is passed as a string but it actually represents an integer category ID * */ public ViewResult List(ProductListViewModel model, string searchString) { if (!String.IsNullOrEmpty(model.categorychosen)) { if (Int32.TryParse(model.categorychosen, out int id)) { ViewModel.Products = Scraper.Scraper.SearchByCategory(_categoryRepository.getCategoryById(id)); if (model.filterSelected == "Price") { ViewModel.Products = ViewModel.Products.OrderBy(o => o.Price); } if (model.filterSelected == "Name") { ViewModel.Products = ViewModel.Products.OrderBy(o => o.Name); } if (model.filterSelected == "Manufacturer") { ViewModel.Products = ViewModel.Products.OrderBy(o => o.Brand); } if (model.filterSelected == "URL") { ViewModel.Products = ViewModel.Products.OrderBy(o => o.SiteUrl); } if (model.filterSelected == "Model") { ViewModel.Products = ViewModel.Products.OrderBy(o => o.Model); } } else { //error parsing id } } if (!String.IsNullOrEmpty(model.searchString)) { ViewModel.Products = Scraper.Scraper.SearchByCategory(_categoryRepository.getCategoryById(1)); ViewModel.Products = ViewModel.Products.Where(s => s.Name.Contains(searchString)); return(View(ViewModel)); } return(View(ViewModel)); }
// GET: Products/Delete public async Task <IActionResult> Delete(int?id) { // Create new instance of the view model ProductListViewModel model = new ProductListViewModel(); if (id == null) { return(NotFound()); } var myprod = await _context.Product.SingleOrDefaultAsync(P => P.ProductID == id); var checkprod = await _context.ProductOrder.FirstOrDefaultAsync(po => po.ProductID == id); if (checkprod != null) { var proddel = await(from p in _context.Product join po in _context.ProductOrder on p.ProductID equals po.ProductID join oo in _context.Order on po.OrderID equals oo.OrderID where oo.PaymentTypeID == null select p).SingleOrDefaultAsync(p => p.ProductID == id); if (proddel == null) { return(View("NoDelete")); } else { var mypo = await _context.ProductOrder.Where(po => po.ProductID == id).ToListAsync(); foreach (var item in mypo) { _context.ProductOrder.Remove(item); await _context.SaveChangesAsync(); } return(View(proddel)); } } else { return(View(myprod)); } }
public ActionResult FuzzyQuery(string queryStr, int?indexNum, int?pageSize = 8) { var productList = (from p in _readFromDb.Products join d in _readFromDb.Discounts on p.Id equals d.ProductId join c in _readFromDb.Categories on p.CategoryId equals c.Id where p.ProductName.Contains(queryStr) && p.IsOnSale == true let cm = _readFromDb.Comments.Where(c => c.ProductId == p.Id) select new ProductListDataModel { ProductId = p.Id, ProductName = p.ProductName, Price = Math.Round((double)p.Price, 2), Discounts = d.Discounts, DiscountPrice = Math.Round((double)((p.Price * d.Discounts) / 10), 2), CommentAmount = cm.Count(), ProductUrl = p.Url, CategoryId = c.Id }); List <ProductListDataModel> pl = new List <ProductListDataModel>(); var paginationList = productList.OrderBy(x => x.ProductId).ToPagedList(indexNum, pageSize); paginationList.ForEach(x => { pl.Add(new ProductListDataModel { ProductId = x.ProductId, ProductName = x.ProductName, Price = x.Price, DiscountPrice = x.DiscountPrice, Discounts = x.Discounts, CommentAmount = x.CommentAmount, ProductUrl = x.ProductUrl, CategoryId = x.CategoryId }); }); ProductListViewModel products = new ProductListViewModel() { PageIndex = paginationList.PageIndex, TotalPage = paginationList.TotalPage, productList = pl, pageBar = paginationList.getPageBar() }; return(View("ProductList", products)); }
public async Task <IActionResult> ShopDetails(long Id = 0, long Cid = 0) { try { ProductListViewModel response = await this._productService.GetProductByCategoryId(Cid); if (response?.productViewModels?.Count > 0) { TempData["Id"] = Id; return(View(response)); } return(RedirectToAction("ProductDetails", "Shop")); } catch (Exception) { throw; } }
/// <summary> /// Returns the ProductList View with the list of products for the seller id provided. /// </summary> /// <param name="id"></param> /// <returns>ProductsList View</returns> public IActionResult ProductList(int id, string sellerName) { var products = _productRepository.GetProductsEnabledBySellerId(id).OrderBy(p => p.ProductName); Console.Write(id); if (products == null) { return(NotFound()); } var productListViewModel = new ProductListViewModel() { Title = sellerName, Products = products.ToList() }; return(View(productListViewModel)); }
public ActionResult Index(int page = 1) { var Products = productRepo.Products.OrderByDescending(p => p.ProductName) .Where(p => p.StatusCode.Equals("STOC")); ProductListViewModel model = new ProductListViewModel { Products = Products.Skip((page - 1) * PAGE_SIZE).Take(PAGE_SIZE), PagingInfo = new PagingInfo { TotalItems = Products.Count(), CurrentPage = page, ItemPerPage = PAGE_SIZE }, Kinds = kindRepo.Kinds, Categories = null, SearchInfo = null }; return(View(model: model)); }
public IActionResult Index(string category, int page = 1, int pageSize = 4) { var filteredProducts = repository.Products.Where(x => category == null || x.Category == category); var products = filteredProducts.Skip(pageSize * (page - 1)).Take(pageSize); var model = new ProductListViewModel() { Products = products, CurrentCategory = category, PagingInfo = new PagingInfo() { Page = page, PageSize = pageSize, TotalItems = filteredProducts.Count() } }; return(View(model)); }
public IActionResult Index(int id) { var productList = new ProductListViewModel(); try { Program.stopwatch.Start(); productList.Categories = categoriesContext.GetAll().ToList(); Program.stopwatch.Stop(); Program.logger.Debug($"Успешно получен список товаров количетво товаров: {productList.Categories.Count()} Затраченное время: {Program.stopwatch.Elapsed}"); } catch (Exception ex) { Program.logger.Error(ex.Message); return(BadRequest(ex)); } return(View(productList)); }
public IActionResult Index(int?page) { var currentPageNum = page.HasValue ? page.Value : 1; var offset = (DefaultPageSize * currentPageNum) - DefaultPageSize; var model = new ProductListViewModel(); model.Products = this.allProducts .Skip(offset) .Take(DefaultPageSize) .ToList(); model.Paging.CurrentPage = currentPageNum; model.Paging.ItemsPerPage = DefaultPageSize; model.Paging.TotalItems = allProducts.Count; return(View(model)); }
public IActionResult List(string category, int page = 1) { const int pageSize = 6; var productViewModel = new ProductListViewModel() { PageInfo = new PageInfo() { TotalItems = _productService.GetCountByCategory(category), CurrentPage = page, ItemsPerPage = pageSize, CurrentCategory = category }, Products = _productService.GetProductsByCategory(category, page, pageSize) }; return(View(productViewModel)); }
ProductListViewModel createModel(int brandId) { var model = new ProductListViewModel(); PrepareViewModel(model, EvolutionResources.bnrProducts, 0, MenuOptionFlag.RequiresNoProduct); model.BrandList = ProductService.FindBrandListItemModel(); if (brandId != 0) { model.SelectedBrandId = brandId; } else { model.SelectedBrandId = (model.BrandList.Count > 0 ? Convert.ToInt32(model.BrandList[0].Id) : 0); } return(model); }
public ActionResult Index(int page = 1, int category = 0) { int pageSize = 10; var products = _ProductService.GetAll(category); ProductListViewModel model = new ProductListViewModel { Products = products.Skip((page - 1) * pageSize).Take(pageSize).ToList(), PageSize = pageSize, PageCount = (int)(Math.Ceiling(products.Count / (double)pageSize)), CurrentCategory = category, CurrentPage = page }; TempData.Add("category", "category"); return(View(model)); }
// [Route("paging/{page?}")] public IActionResult Index(int p = 1) { var currentPageNum = p; var offset = (DefaultPageSize * currentPageNum) - DefaultPageSize; var model = new ProductListViewModel(); model.Products.Data = this.allProducts .Skip(offset) .Take(DefaultPageSize) .ToList(); model.Products.PageNumber = currentPageNum; model.Products.PageSize = DefaultPageSize; model.Products.TotalItems = allProducts.Count; return(View(model)); }
public ActionResult Index(int page = 1, int categoryId = 0) { //Şimdilik Sabit int pageSize = 10; var products = _productService.GetByCategory(categoryId); ProductListViewModel model = new ProductListViewModel { //İlk page-1 kadar ürünü atla.Pagesize kadar ürünü al. Products = products.Skip((page - 1) * pageSize).Take(pageSize).ToList(), PageCount = (int)Math.Ceiling(products.Count / (double)pageSize), PageSize = pageSize, CurrentCategoryId = categoryId, CurrentPage = page }; return(View(model)); }
public IActionResult Index(int page = 1, int category = 0) { int pageSize = 10; var products = _productService.GetByCategoryId(category); ProductListViewModel model = new ProductListViewModel { Products = products.Skip((page - 1) * pageSize).Take(pageSize).ToList(), PageCount = (int)Math.Ceiling(products.Count / (double)pageSize), PageSize = pageSize, CurrentCategory = category, CurrentPage = page }; return(View(model)); }
public void Can_Paginate() { // Mock <IProductRepository> mock = GetMock(); ProductController controller = new ProductController(mock.Object); controller.PageSize = 3; // ProductListViewModel result = controller.List(null, 2).ViewData.Model as ProductListViewModel; // Product[] prodArray = result.Products.ToArray(); Assert.True(prodArray.Length == 2); Assert.Equal("P4", prodArray[0].Name); Assert.Equal("P5", prodArray[1].Name); }
// action-metod List returnerar till view List public ViewResult List() { // skickar med fliknamnet till webben ViewBag.Title = "Bageri 2.0"; // rubrik till webbsidan ViewBag.Rubrik = "Produktlista"; //ViewBag.Message = "Welcome to Pie shop"; // skapar en instans av klassen ProductListViewModel // urval: alla pajer ProductListViewModel ProduktLista = new ProductListViewModel(); ProduktLista.Lista = accessProdukt.AllProducts; // skickar data till vyn List return(View(ProduktLista)); }
public IActionResult List(string category, int pageNumber = 1) { category = category?.Replace("-", " "); var model = new ProductListViewModel { Products = _productRepository.GetProducts(category, 2, pageNumber), PagingInfo = new Models.Commons.PagingInfo { CurrentPage = pageNumber, ItemsPerPages = 2, TotalItems = _productRepository.TotalCount(category), }, CurrentCategory = category }; return(View(model)); }
public ActionResult Index() { // Gets the products list from the productsRepository class var products = _productRepository.Products.ToList(); // Gets the categories from the categoryRepository class var categories = _categoryRepository.Categories.ToList(); // Creates a ProductListViewModel instance and initializes it ProductListViewModel model = new ProductListViewModel(); // Adds all the products to the view model model.Products = products; model.Categories = categories; // Return to the view with the view model information return(View(model)); }
public void Can_Paginate() { //arrange Mock <IProductRepository> mock = getMockProductRepository(); ProductController controller = new ProductController(mock.Object); controller.PageSize = 3; // 3 products per page //act ProductListViewModel result = (ProductListViewModel)controller.List(null, page: 2).Model; //assert Product[] productsOnPage = result.Products.ToArray(); Assert.IsTrue(productsOnPage.Length == 2); Assert.AreEqual(productsOnPage[0].Name, "P4"); Assert.AreEqual(productsOnPage[1].Name, "P5"); }
public ViewResult List(int page = 1) { var model = new ProductListViewModel { Products = _repository.Products .OrderBy(p => p.ProductId) .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = _repository.Products.Count() } }; return(View(model)); }
public ActionResult Products() { dbOBJ.CatagoriesTable.ToList(); dbOBJ.ProductsTable.ToList(); dbOBJ.SellerTable.ToList(); dbOBJ.sellerInfoTable.ToList(); var productModel = new ProductListViewModel(); productModel.CatagoryList = GetCategories(); productModel.SellerList = GetSellers(); Product productobj = new Product(); return(View("ViewAddProduct", productModel)); }
public ActionResult Index(int page = 1, int categoryId = 0) { int pageSize = 10; //var products = _productService.GetAll(); // encapsulation yapmak gerekir best practice acisindan // product nesnesini view modele cevirip modele basacagiz var products = _productService.GetByCategory(categoryId); // kategoriye bagli urunleri getiriyoruz simdi var model = new ProductListViewModel { Products = products.Skip((page - 1) * pageSize).Take(pageSize).ToList(), PageCount = (int)Math.Ceiling(products.Count / (double)pageSize), PageSize = pageSize, CurrentCategory = categoryId, CurrentPage = page }; return(View(model)); }
public MainViewModel(int sel, int selList) { curWeek = new List<string>(); curWeek.Add("Текущая неделя"); curWeek.Add("Следующая неделя"); curList = new List<string>(); curList.Add("До конца недели"); curList.Add("На следующую неделю"); curList.Add("На завтра"); Selected = sel; SelectedList = selList; dateStart = DateStartCount(Selected); dateEnd = dateStart.AddDays(6); Id = GetMenuId(); Menus = new MenuDayViewModel(Id); Products = new ProductListViewModel(selList); Today = new TodayMenuViewModel(); }
public ViewResult List(string category, int page = 1) { ProductListViewModel model = new ProductListViewModel { Products = repository.Products.Where(p => category == null || p.Category == category).OrderBy(p => p.ProductID).Skip((page - 1) * PageSize).Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = category == null? repository.Products.Count() : repository.Products.Where(e => e.Category == category).Count() }, CurrentCategory = category, }; return(View(model)); }
public IActionResult Increasing(SearchListInputModel input, int page = 1) { if (page <= 0) { return(this.NotFound()); } const int ItemsPerPage = 8; var viewModel = new ProductListViewModel() { ItemsPerPage = ItemsPerPage, PageNumber = page, Count = this.productsService.GetCount(), Products = this.productsService.GetAllIncreasing <ProductInListViewModel>(input.Id, page, ItemsPerPage), }; return(this.View(viewModel)); }
public ViewResult FilteredList(string search = "", int page = 1) { var model = new ProductListViewModel { Elements = _repository.Products.Where(p => p.Name.Contains(search)) .OrderBy(p => p.Id) .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = _repository.Products.Count(p => p.Name.Contains(search)) }, }; return(View(model)); }
// GET: Ordering public ActionResult Index(string keyword,string category,string sort,bool? isSeasonalProduct,bool? isOffProduct) { var products = db.Products.ToList(); if(!string.IsNullOrEmpty(keyword)) { products = products.Where(p => p.Name.Contains(keyword)).ToList(); } if (!string.IsNullOrEmpty(category)) { var categoryId = db.ProductCategories.Where(c => c.Name == category).Single().Id; //products = products.Where(p => p.Category.Id == categoryId).ToList(); products = (from pro in db.Products join cate in db.ProductCategories on pro.Category.Id equals cate.Id where cate.Name == category select pro).ToList(); } switch(sort) { case "priceDesc": products = products.OrderByDescending(p => p.Price).ToList(); break; case "priceAsc": products = products.OrderBy(p => p.Price).ToList(); break; default: break; } if(isSeasonalProduct.HasValue) { if(isSeasonalProduct==true) { products = products.Where(p => p.IsSeasonalProduct == true).ToList(); } } if (isOffProduct.HasValue) { if (isOffProduct == true) { products = products.Where( p => { if(p.CurrentDiscount.HasValue) { return p.CurrentDiscount !=1? true : false; } else { return false; } } ).ToList(); } } var vm = new ProductListViewModel { CurrentKeyword=keyword, CurrentCategory=category, CurrentSort=sort, CurrentIsSeasonalProduct=isSeasonalProduct??false, CurrentIsOffProduct=isOffProduct??false, Products = products }; return View(vm); }