// GET: Products public ActionResult Index(int?page) { int pageSize = 9; int pageNumber = (page ?? 1); var websiteContent = _unitOfWork.WebsiteContent.GetWebsiteContent(); var model = new ProductsPageViewModel() { ProductList = _unitOfWork.Product.GetActiveProducts().Select(pl => new ProductListViewModel { Id = pl.Id, Name = pl.Name, FeaturedImage = _unitOfWork.ProductImage.GetProductImageByProductId(pl.Id).FilePath + "/" + _unitOfWork.ProductImage.GetProductImageByProductId(pl.Id).FileName }).ToPagedList(pageNumber, pageSize), ProductsTitle = websiteContent.ProductsTitle, ProductsSubtitle = websiteContent.ProductsSubtitle, ProductsMainImageName = websiteContent.ProductsMainImageName, ProductsMainImagePath = websiteContent.ProductsMainImagePath }; ViewBag.TopImage = websiteContent.ProductsMainImagePath + "/" + websiteContent.ProductsMainImageName; ViewBag.Headline = websiteContent.ProductsTitle; ViewBag.SubHeadline = websiteContent.ProductsSubtitle; return(View(model)); }
public IActionResult Index(PageParametersViewModel pageParams) { List <Product> AllProds = this.ProdRepo.GetAll().ToList(); ProductListHelper productHelper = new ProductListHelper(AllProds, ref pageParams, MaxPageSize); IEnumerable <Product> SelectedProds = productHelper.GetProdsBySearch(); int TotalPages = productHelper.TotalPages(); ProductsPageViewModel productsPage = new ProductsPageViewModel { Products = SelectedProds, PageParams = new PageViewModel { TotalPages = TotalPages, PageParams = pageParams }, SearchBarParams = new SearchBarViewModel { manufacturers = this.ManuRepo.GetAll().ToList(), pageParams = pageParams } }; return(View(productsPage)); }
public async Task <IActionResult> ProductsPage() { if (!LoggedIn()) { return(RedirectToAction("Login")); } List <Product> Products = await _db.Products.ToListAsync(); Dictionary <int, Brand> Brands = await _db.Brands.ToDictionaryAsync(p => p.Id); Dictionary <int, Category> Categories = await _db.Categories.ToDictionaryAsync(p => p.Id); Dictionary <int, Gender> Genders = await _db.Genders.ToDictionaryAsync(p => p.Id); Dictionary <int, string> ImgUrls = new Dictionary <int, string>(); foreach (var item in Products) { ImgUrls.Add(item.Id, JsonSerializer.Deserialize <string[]>(item.ImgUrls).FirstOrDefault()); } ProductsPageViewModel model = new ProductsPageViewModel { Products = Products, Brands = Brands, Categories = Categories, Genders = Genders, ImgUrls = ImgUrls }; return(View(model)); }
public void TestMethod1() { //Produit p = new Produit("58", "aziz", "eeee"); //IDAoImpProduit daopr = new IDAoImpProduit(); //bool veri=daopr.ajout(p); //Assert.IsTrue(veri); //IFakeDAO fake = Substitute.For<ISQliteDB>(); // fake.ajout().Returns(true); // ConsoleProduit d = new ConsoleProduit(); // bool pp = d.ajoutt(fake); // Assert.IsTrue(pp); //Arrange var sqlite = new SQLiteDb(); var productStore = new SQLiteProductStore(sqlite); var pageService = Substitute.For <IPageService>(); var addService = Subtitute.For <IProductStore>(); var vm = new ProductsPageViewModel(productStore, pageService); //Act vm.LoadDataCommand.Execute(null); var x = vm.Products; vm.AddProductCommand.Execute(null); //Assert Assert.IsNotNull(x); }
public void Setup() { _productStore = new Mock <IProductStore>(); _pageService = new Mock <IPageService>(); _viewModelProductsPage = new ProductsPageViewModel(_productStore.Object, _pageService.Object); _viewModel = new ProductViewModel(); _vmd = new ProductsDetailViewModel(_viewModel, _productStore.Object, _pageService.Object); }
public ProductsPage() { var productStore = new SQLiteProductStore(DependencyService.Get <ISQLiteDb>()); var pageService = new PageService(); ViewModel = new ProductsPageViewModel(productStore, pageService); InitializeComponent(); }
public ActionResult Products(int categoryId = 2) { NorthwindDb db = new NorthwindDb(_connectionString); ProductsPageViewModel vm = new ProductsPageViewModel(); vm.Products = db.GetProductsForCategory(categoryId); vm.CategoryName = db.GetCategoryName(categoryId); return(View(vm)); }
public void InitializationShouldLoadAvailableProducts() { // Arrange var vm = new ProductsPageViewModel(); // Act // Assert Assert.NotEmpty(vm.Products); }
public void InitializationShouldSetHeader() { // Arrange var vm = new ProductsPageViewModel(); // Act // Assert Assert.NotEqual("", vm.Header); }
public async Task <IActionResult> Index(string subCategoryCode, int page = 1, int size = 20, string order = "DESC", string field = "") { var products = new ProductsPageViewModel() { Categorys = new List <Category>(), //buscar da base Subcategorys = new List <Subcategory>(), //buscar da base Products = await _productService.GetAll(page, size, Order.DESC, field, subCategoryCode) }; return(View(products)); }
public ProductsPage (ProductsPageViewModel vm) { InitializeComponent (); BindingContext = vm; productListView.ItemTapped += productListView_ItemTapped; AbortButton.Clicked += (object sender, EventArgs e) => Navigation.PopAsync(); BuyButton.Clicked += OnBuyClicked; }
public IActionResult SaleProducts(int?page) { if (User.Identity.IsAuthenticated) { cartItems = unitOfWork.CartItems.GetUserCartItems(User.FindFirst(ClaimTypes.NameIdentifier).Value).ToList(); } var model = new ProductsPageViewModel(categories, cartItems); model.Title = "ON SALE"; model.ProductsPage = unitOfWork.Products.GetOnSale().ToPagedList(page ?? 1, 12); return(View("ProductsPage", model)); }
public IActionResult Category(int?page, int id, string name) { if (User.Identity.IsAuthenticated) { cartItems = unitOfWork.CartItems.GetUserCartItems(User.FindFirst(ClaimTypes.NameIdentifier).Value).ToList(); } var model = new ProductsPageViewModel(categories, cartItems); model.Id = id; List <Product> products = unitOfWork.Categories.GetProductsWImg(id).ToList(); model.ProductsPage = products.ToPagedList(page ?? 1, 12); model.Title = name; return(View("ProductsPage", model)); }
public ActionResult SaveProductsContent(ProductsPageViewModel model) { var websiteContent = _unitOfWork.WebsiteContent.GetWebsiteContent(); var HomepagePath = "/DynamicContent/ProductsContent"; websiteContent.ProductsTitle = model.ProductsTitle; websiteContent.ProductsSubtitle = model.ProductsSubtitle; if (model.ProductsMainImageFile != null) { websiteContent.ProductsMainImageName = model.ProductsMainImageFile.FileName; websiteContent.ProductsMainImagePath = HomepagePath; model.ProductsMainImageFile.SaveAs(Path.Combine(Server.MapPath(HomepagePath), model.ProductsMainImageFile.FileName)); } _unitOfWork.Complete(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Index(string sort, string name, int page) { if (sort != null) { var sortedProducts = await this.productsService.GetProductsAndSortAsync(sort); var sortedProductsViewModel = new ProductsPageViewModel { ProductPerPage = ServicesConstants.ProductsCountPerPage, CurrentPage = page, Products = sortedProducts, }; return(this.View(sortedProductsViewModel)); } if (name != null) { var filteredProducts = await this.productsService.GetProductsByCategoryAsync(name); var filteredProductsViewModel = new ProductsPageViewModel { ProductPerPage = ServicesConstants.ProductsCountPerPage, CurrentPage = page, Products = filteredProducts, }; return(this.View(filteredProductsViewModel)); } else { var products = await this.productsService.GetAllProductsAsync(); var productsViewModel = new ProductsPageViewModel { ProductPerPage = ServicesConstants.ProductsCountPerPage, CurrentPage = page, Products = products, }; return(this.View(productsViewModel)); } }
public async Task <IActionResult> Search(SearchViewModel inputModel) { if (!this.ModelState.IsValid) { return(this.View("Error404")); } var programs = await this.searchesService.GetProgramsBySearchTextAsync(inputModel); if (programs != null) { return(this.View("~/Views/Programs/Index.cshtml", programs)); } var products = await this.searchesService.GetProductsBySearchTextAsync(inputModel); if (products != null) { var productsPageViewModel = new ProductsPageViewModel { ProductPerPage = ServicesConstants.PostsCountPerPage, Products = products, }; return(this.View("~/Views/Products/Index.cshtml", productsPageViewModel)); } var posts = await this.postsService.GetPostsBySearchAsync(inputModel); if (posts != null) { var postPageViewModel = new PostPageViewModel { PostsPerPage = ServicesConstants.PostsCountPerPage, Posts = posts, }; return(this.View("~/Views/Posts/Index.cshtml", postPageViewModel)); } return(this.View("Error404")); }
public IActionResult SelectProductsInStorage(string storageName, int page = 1) { List <Product> products = _db.Products.Include(p => p.Place).Include(s => s.Place.Storage) .Where(s => s.Place.Storage.Name == storageName).ToList(); int pageSize = 15; int count = products.Count(); List <Product> selectedItems = products.Skip((page - 1) * pageSize).Take(pageSize).ToList(); PageViewModel pageViewModel = new PageViewModel(count, page, pageSize); ProductsPageViewModel viewModel = new ProductsPageViewModel { PageViewModel = pageViewModel, Products = selectedItems }; ViewBag.StorageName = storageName; return(View("Products", viewModel)); }
public IActionResult SearchProducts(int?page, string SearchString) { if (User.Identity.IsAuthenticated) { cartItems = unitOfWork.CartItems.GetUserCartItems(User.FindFirst(ClaimTypes.NameIdentifier).Value).ToList(); } var model = new ProductsPageViewModel(categories, cartItems); model.Title = "Search Results"; model.ProductsPage = unitOfWork.Products.GetSearchName(SearchString).ToPagedList(page ?? 1, 12); var productTags = unitOfWork.Tags.GetProductsTags(SearchString); if (productTags != null) { foreach (var item in productTags) { model.ProductsPage.Append(item.Product); } } return(View("ProductsPage", model)); }
public IActionResult Products(int page = 1) { int pageSize = 15; List <string> storagesNames = _db.Storages.Select(x => x.Name).Distinct().ToList(); List <Product> products = new List <Product>(); foreach (string name in storagesNames) { products.AddRange(_db.Products.Include(p => p.Place.Storage).Include(s => s.Place).Where(s => s.Place.Storage.Name == name).ToList()); } int count = products.Count(); List <Product> selectedItems = products.Skip((page - 1) * pageSize).Take(pageSize).ToList(); PageViewModel pageViewModel = new PageViewModel(count, page, pageSize); ProductsPageViewModel viewModel = new ProductsPageViewModel { PageViewModel = pageViewModel, Products = selectedItems }; return(View(viewModel)); }
public ProductsPage() { BindingContext = new ProductsPageViewModel(); InitializeComponent(); }
public async Task <IActionResult> GetAllProductsAsync(int pageIndex, int pageSize) { ProductsPageViewModel productsPageViewModel = await _productsService.GetAllProductsAsync(pageIndex, pageSize); return(new OkObjectResult(productsPageViewModel)); }
public async Task <IActionResult> FindProductsAsync(string sku, int pageIndex, int pageSize) { ProductsPageViewModel productsPageViewModel = await _productsService.FindProductsAsync(sku, pageIndex, pageSize); return(new OkObjectResult(productsPageViewModel)); }