public void AddCatalogItemCommandIsNotNullTest() { var catalogService = new CatalogMockService(); var catalogViewModel = new CatalogViewModel(catalogService); Assert.NotNull(catalogViewModel.AddCatalogItemCommand); }
public IActionResult Catalog(int id, string keyword, int?pageSize, string sortBy, int page = 1) { ViewData["BodyClass"] = "shop_grid_full_width_page"; var catalogViewModel = new CatalogViewModel(); catalogViewModel.MetaKeyword = string.Empty; catalogViewModel.MetaDescription = string.Empty; if (pageSize == null) { pageSize = _configuration.GetValue <int>("PageSize"); } if (string.IsNullOrEmpty(sortBy)) { sortBy = _configuration.GetValue <string>("SortType"); } catalogViewModel.PageSize = pageSize; catalogViewModel.SortType = sortBy; catalogViewModel.Data = _productService.GetAllPaging(id, string.Empty, page, pageSize.Value, sortBy); catalogViewModel.Category = _productCategoryService.GetById(id); catalogViewModel.Title = catalogViewModel.Category.Name; return(View(catalogViewModel)); }
public IActionResult Shop(int?sectionId, int?brandId, int page = 1) { int?pageSize = int.TryParse(_configuration["PageSize"], out int page_size) ? page_size : (int?)null; PageProductsDTO products = _catalogData.GetProducts(new ProductFilter { BrandId = brandId, SectionId = sectionId, Page = page, PageSize = pageSize }); CatalogViewModel catalogViewModel = new CatalogViewModel { BrandId = brandId, SectionId = sectionId, Products = products.Products.FromDTO().ToView(), PageViewModel = new PageViewModel() { PageNumber = page, TotalItems = products.TotalCount, PageSize = pageSize.GetValueOrDefault() } }; return(View(catalogViewModel)); }
public async Task <IActionResult> Catalog(int id, [FromQuery] int?pageSize, [FromQuery] string sortBy, [FromQuery] int?sortprice, [FromQuery] int page = 1) { var catalog = new CatalogViewModel(); ViewData["BodyClass"] = "shop_grid_full_width_page"; if (pageSize == null) { pageSize = _configuration.GetValue <int>("PageSize"); } catalog.PageSize = pageSize; catalog.SortType = sortBy; foreach (var item in catalog.SortPrice) { if (item.Value == sortprice) { item.Selected = true; } else { item.Selected = false; } } catalog.Data = _productService.GetAllPaging(id, string.Empty, page, pageSize.Value, sortBy, sortprice); catalog.Category = await _productCategoryService.GetById(id); return(View(catalog)); }
public ActionResult ComponentsCatalog(string[] Brands, string returnUrl, CommonSort SortByIncreaseName = CommonSort.Нет, CommonSort SortByIncreasePrice = CommonSort.Нет, CommonSort SortByIncreaseProducedAt = CommonSort.Нет, string category = "Процессоры", int?minPrice = null, int?maxPrice = null, int page = 1, int pageSize = 20) { ViewBag.returnUrl = returnUrl; if (Session["CurrentFilter"] == null || ((PcComponentsFilter)Session["CurrentFilter"]).Category != category) { Session["CurrentFilter"] = new PcComponentsFilter(); } PcComponentsFilter curFilter = new PcComponentsFilter { SortByIncreaseName = SortByIncreaseName, SortByIncreasePrice = SortByIncreasePrice, SortByIncreaseProducedAt = SortByIncreaseProducedAt, MinPrice = minPrice, MaxPrice = maxPrice, Brands = Brands, Category = category }; if (curFilter.ValidateInputParameters()) { Session["CurrentFilter"] = curFilter; } else { ModelState.AddModelError("CatalogViewModel", curFilter.ErrorMessage); } IEnumerable <Good> allGoods = componentsUnit.GetGoodsDependsOnCategory(category); IEnumerable <Good> filteredGoods = componentsUnit.GetGoodsDependsOnFilter(category, (PcComponentsFilter)Session["CurrentFilter"]); if (allGoods != null && filteredGoods != null) { return(View(CatalogViewModel <Good> .GetCatalogViewModel(page, pageSize, filteredGoods, allGoods, category))); } throw new HttpException(404, "Page Not Found"); }
public async void ProductsNotShouldBeEmpty() { //Arrange Moq.Mock <IProductService> productServiceMock = new Moq.Mock <IProductService>(); productServiceMock.Setup(x => x.GetProducts()) .Returns(Task.FromResult(new List <Product>() { new Product() { Id = 1, Name = "Produto Teste" } })); Moq.Mock <IOrderService> orderServiceMock = new Moq.Mock <IOrderService>(); orderServiceMock.Setup(x => x.CreateOrder()) .Returns(Task.FromResult(new Order(1))); Moq.Mock <ICategoryService> categoryServiceMock = new Moq.Mock <ICategoryService>(); Moq.Mock <IProductPromotionService> productPromotionServiceMock = new Moq.Mock <IProductPromotionService>(); CatalogViewModel catalogViewModel = new CatalogViewModel(productServiceMock.Object, orderServiceMock.Object, categoryServiceMock.Object, productPromotionServiceMock.Object); //Act await catalogViewModel.Initialize(); var actual = catalogViewModel.Products; //Assert Assert.NotEmpty(actual); }
public IActionResult Shop(int?sectionId, int?brandId) { var products = _productData.GetProducts(new ProductFilter { BrandId = brandId, SectionId = sectionId }); var model = new CatalogViewModel { BrandId = brandId, SectionId = sectionId, Products = products.Select(p => new ProductViewModel { Id = p.Id, ImageUrl = p.ImageUrl, Name = p.Name, Order = p.Order, Price = p.Price, Brand = p.Brand?.Name ?? String.Empty }).OrderBy(p => p.Order).ToList() }; return(View(model)); }
public IActionResult Index(int?brandId, int?sectionId) { var filter = new ProductFilter { BrandId = brandId, SectionId = sectionId }; var products = _ProductData.GetProducts(filter); var catalogViewModel = new CatalogViewModel { SectionId = sectionId, BrandId = brandId, Products = products .OrderBy(p => p.Order) .Select(p => new ProductViewModel { Id = p.Id, Name = p.Name, Price = p.Price, ImageUrl = p.ImageUrl }) }; return(View(catalogViewModel)); }
public IActionResult Update(int id) { var cvm = new CatalogViewModel(); cvm.Catalog = _catalogRepository.GetById(id); return(View(cvm)); }
public async Task <IActionResult> Catalog(Guid id) { var catalog = await _api.Pages.GetByIdAsync <CatalogPage>(id); var sitemap = await _api.Sites.GetSitemapAsync(); var model = new CatalogViewModel { CatalogPage = catalog, Categories = sitemap .Where(x => x.Id == catalog.Id) .SelectMany(x => x.Items) .Select(x => { var page = _api.Pages.GetByIdAsync <CategoryPage>(x.Id).Result; return(new CategoryItem { Title = page.Title, Description = page.CategoryDetail.Description, PageUrl = page.Permalink, ImageUrl = page.CategoryDetail.CategoryImage.Resize(_api, 200) }); }) }; return(View(model)); }
public void ClearFilterCommandIsNotNullTest() { var catalogService = new CatalogMockService(); var catalogViewModel = new CatalogViewModel(catalogService); Assert.NotNull(catalogViewModel.ClearFilterCommand); }
public CatalogView( CatalogViewModel viewModel ) { InitializeComponent(); // Set the ViewModel as this View's data context. this.DataContext = viewModel; }
public void Move_focus() { WpfTestHelper.WithWindow2(async w => { var model = new CatalogViewModel(); var view = Bind(model); w.Content = view; await view.WaitLoaded(); scheduler.Start(); await view.WaitIdle(); var names = view.Descendants <DataGrid2>().First(x => x.Name == "CatalogNames"); var forms = view.Descendants <DataGrid2>().First(x => x.Name == "Catalogs"); names.Focus(); Assert.IsTrue(names.IsKeyboardFocusWithin); Assert.IsFalse(forms.IsKeyboardFocusWithin); var id = session.Query <CatalogName>() .First(c => c.HaveOffers && session.Query <Catalog>().Count(x => x.HaveOffers && x.Name == c) > 1) .Id; names.SelectedItem = names.Items.OfType <CatalogName>().First(x => x.Id == id); scheduler.Start(); names.RaiseEvent(WpfTestHelper.KeyArgs(names, Key.Enter)); await view.WaitIdle(); Assert.IsFalse(names.IsKeyboardFocusWithin); Assert.IsTrue(forms.IsKeyboardFocusWithin); }); }
public IActionResult Shop(int?brandId, int?sectionId) { var products = _productData.GetProducts(new ProductFilter() { BrandId = brandId, SectionId = sectionId }); var catalogVM = new CatalogViewModel() { BrandId = brandId, SectionId = sectionId, Products = products.Select(p => new ProductViewModel() { BrandId = p.BrandId, Order = p.Order, Name = p.Name, SectionId = p.SectionId, Id = p.Id, ImageUrl = p.ImageUrl, Price = p.Price }).OrderBy(_ => _.Order) }; return(View(catalogVM)); }
public IActionResult Shop(int?SectionId, int?BrandId, int Page = 1) { var page_size = int.Parse(_Configuration["PageSize"]); var products = _ProductData.GetProducts(new ProductFilter { BrandId = BrandId, SectionId = SectionId, Page = Page, PageSize = page_size }); var model = new CatalogViewModel { BrandId = BrandId, SectionId = SectionId, Products = products.Products.Select(p => new ProductViewModel { Id = p.Id, Name = p.Name, ImageUrl = p.ImageUrl, Order = p.Order, Price = p.Price, Brand = p.Brand?.Name ?? string.Empty }).OrderBy(p => p.Order).ToArray(), PageViewModel = new PageViewModel { PageSize = page_size, PageNumber = Page, TotalItems = products.TotalCount } }; return(View(model)); }
public void Quick_search() { var term = session.Query <Catalog>().First(c => c.HaveOffers).FullName.Substring(0, 1); WpfTestHelper.WithWindow2(async w => { var model = new CatalogViewModel(); var view = Bind(model); w.Content = view; await view.WaitLoaded(); var searchCheck = view.Descendants <CheckBox>().First(c => c.Name == "CatalogSearch"); searchCheck.IsChecked = true; await view.WaitIdle(); scheduler.Start(); var grid = view.Descendants <DataGrid>().First(g => g.Name == "Items"); grid.SendText(term); var search = view.Descendants <TextBox>().First(b => b.Name == "SearchText"); Assert.IsTrue(search.IsVisible); Assert.AreEqual(term, search.Text); search.Text = ""; var enable = view.Descendants <CheckBox>().First(c => c.Name == "IsQuickSearchEnabled"); enable.IsChecked = true; grid.SendText(term); Assert.AreEqual("", search.Text); var quicksearch = view.Descendants <ContentControl>().First(c => c.Name == "QuickSearch") .Descendants <TextBox>().First(c => c.Name == "SearchText"); Assert.AreEqual(term, quicksearch.Text, quicksearch.GetHashCode().ToString()); }); }
public ActionResult Edit([Bind(Include = "CatalogId, Code, Description, ProductsViewModel")] CatalogViewModel catalog) { if (ModelState.IsValid) { _unitOfWork.CatalogManager.UpdateCatalog(new Catalog { CatalogId = catalog.CatalogId, Code = catalog.Code, Description = catalog.Description }); List <Product> products = catalog.ProductsViewModel .Where(s => s.IsSelected == true) .Select(x => new Product { ProductId = x.ProductId }).ToList(); _unitOfWork.ProductCatalogManager.UpdateProductCatalog(products, catalog.CatalogId); _unitOfWork.Save(); return(RedirectToAction("Index", "Catalog")); } return(View(catalog)); }
public IActionResult Catalog([FromServices] IRepository dataDase, int catalogID = -1) { CatalogViewModel catalogviewmodel = new CatalogViewModel(); try { var catalogs = dataDase.GetAllCatalogDTOs(); if (catalogID < 0) { catalogID = catalogs.First().Id; } var goods = dataDase.GetGoodDTOsByCataligId(catalogID).GetDiscount(); catalogviewmodel = new CatalogViewModel(catalogs, goods); } catch (NotFoundExeption ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(BadRequest($"something wrong in {ex.Source}")); } return(View(catalogviewmodel)); }
public async Task <IActionResult> Buy(CatalogViewModel model) { var commodityDAO = await _context.Commodities .SingleOrDefaultAsync(c => c.Id == model.BuyingId); if (commodityDAO == null) { return(NotFound(model.BuyingId)); } var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var commodity = commodityDAO.Read(); using (var transaction = _context.Database.BeginTransaction()) { if (!user.CanBuy(commodity)) { return(BadRequest("お金が足りません")); } user.Buy(commodity, _context); await _context.SaveChangesAsync(); transaction.Commit(); } return(Ok()); }
public IActionResult Shop(int?categoryId, int?brandId) { var products = _productService.GetProducts( new ProductsFilter { CategoryId = categoryId, BrandId = brandId }); var catalogViewModel = new CatalogViewModel { BrandId = brandId, CategoryId = categoryId, Products = products.Select(p => new ProductViewModel { Id = p.Id, ImageUrl = p.ImageUrl, Name = p.Name, Order = p.Order, Price = p.Price, IsSale = p.IsSale, IsNew = p.IsNew, BrandName = p.Brand?.Name ?? string.Empty }) .OrderBy(p => p.Order) .ToList() }; return(View(catalogViewModel)); }
public IActionResult Products(int?categoryId, int?brandId) { // получаем список отфильтрованных продуктов var products = _productService.GetProducts( new Domain.Filters.ProductFilter { BrandId = brandId, CategoryId = categoryId }); // конвертируем в CatalogViewModel var model = new CatalogViewModel() { BrandId = brandId, CategoryId = categoryId, Products = products.Select(p => new ProductViewModel() { Id = p.Id, ImageUrl = p.ImageUrl, Name = p.Name, Order = p.Order, Price = p.Price, BrandName = p.Brand?.Name ?? string.Empty }).OrderBy(p => p.Order).ToList() }; return(View(model)); }
public ActionResult Create([Bind(Include = "Code, Description, ProductsViewModel")] CatalogViewModel catalog) { if (ModelState.IsValid) { _unitOfWork.CatalogManager.CreateCatalog(new Catalog { Code = catalog.Code, Description = catalog.Description }); foreach (var p in catalog.ProductsViewModel) { if (p.IsSelected) { var productCatalog = new ProductCatalog(); productCatalog.CatalogId = catalog.CatalogId; productCatalog.ProductId = p.ProductId; _unitOfWork.ProductCatalogManager.AddProductCatalog(productCatalog); } } _unitOfWork.Save(); return(RedirectToAction("Index", "Catalog")); } return(View(catalog)); }
public IActionResult Shop(int?CategoryId, int?BrandId, int Page = 1) { var page_size = int.Parse(config["PageSize"]); var products = _productService.GetProducts( new ProductFilter { BrandId = BrandId, CategoryId = CategoryId, Page = Page, PageSize = page_size }); // сконвертируем в CatalogViewModel var model = new CatalogViewModel() { BrandId = BrandId, CategoryId = CategoryId, Products = products.Products.Select(p => new ProductViewModel() { Id = p.Id, ImageUrl = p.ImageUrl, Name = p.Name, Order = p.Order, Price = p.Price, BrandName = p.Brand.Name }).OrderBy(p => p.Order).ToList(), PageViewModel = new PageViewModel { PageNumber = Page, PageSize = page_size, TotalItems = products.TotalCount } }; return(View(model)); }
public IActionResult Shop(int?SectionId, int?BrandId, int Page = 1) { var page_size = int.Parse(_Configuration[PageSize]); var products = _ProductData.GetProducts(new ProductFilter { SectionId = SectionId, BrandId = BrandId, Page = Page, PageSize = page_size }); var catalog_model = new CatalogViewModel { BrandId = BrandId, SectionId = SectionId, Products = products.Products .Select(product => product.FromDTO()) .Select(ProductViewModelMapper.CreateViewModel), PageViewModel = new PageViewModel { PageSize = page_size, PageNumber = Page, TotalItmes = products.TotalCount } }; return(View(catalog_model)); }
protected override void OnAppearing() { base.OnAppearing(); // Create Binding context for Catalog BindingContext = new CatalogViewModel(); }
private CatalogViewModel GetStandardViewModel() { var container = GetPopulatedContainer(); var viewModel = new CatalogViewModel(container); return(viewModel); }
public void TypePropertyIsNullWhenViewModelInstantiatedTest() { var catalogService = new CatalogMockService(); var catalogViewModel = new CatalogViewModel(catalogService); Assert.Null(catalogViewModel.Type); }
private CatalogViewModel GetCustomViewModel(IPersonService service, CatalogOrder currentOrder) { var container = GetPopulatedContainer(service, currentOrder); var viewModel = new CatalogViewModel(container); return(viewModel); }
public void IsFilterPropertyIsFalseWhenViewModelInstantiatedTest() { var catalogService = new CatalogMockService(); var catalogViewModel = new CatalogViewModel(catalogService); Assert.False(catalogViewModel.IsFilter); }
public IActionResult Shop(int?sectionId, int?brandId) { var products = _productService.GetProducts( new ProductFilter() { SectionId = sectionId, BrandId = brandId }); // сконвертируем в CatalogViewModel var model = new CatalogViewModel() { BrandId = brandId, SectionId = sectionId, Products = products.Select(p => new ProductViewModel() { Id = p.Id, ImageUrl = p.ImageUrl, Name = p.Name, Order = p.Order, Price = p.Price }).OrderBy(p => p.Order).ToList() }; return(View(model)); }
public IActionResult Shop(int?categoryId, int?brandId) { // Получение списока отфильтрованных продуктов var products = _productData.GetProducts(new ProductFilter { BrandId = brandId, CategoryId = categoryId }); // Конвертация в CatalogViewModel var model = new CatalogViewModel() { BrandId = brandId, SectionId = categoryId, Products = products.Select(p => new ProductViewModel() { Id = p.Id, ImageUrl = p.ImageUrl, Name = p.Name, Order = p.Order, Price = p.Price, BrandName = p.Brand?.Name ?? string.Empty //BrandName = p.Brand != null ? p.Brand.Name : string.Empty }).OrderBy(p => p.Order).ToList() }; return(View(model)); }
// ************************************** // URL: /CatalogManagement/Detail/5 // ************************************** public virtual ActionResult Detail(int id) { try { var user = Account.User(); var catalog = CatalogManagementService.GetCatalogDetail(id); if (catalog == null) { this.FeedbackError("This catalog does not exist or you do not have admin access to it."); return RedirectToAction(Actions.Index()); } var vm = new CatalogViewModel(); vm.PageTitle = "Catalog Management"; vm.NavigationLocation = new string[] { "Admin" }; vm.AllowEdit = user.IsSuperAdmin() || user.IsAtLeastInCatalogRole(Roles.Admin, id); vm.ActiveUserId = Account.User().UserId; vm.MyCatalogs = Account.User().MyAdminCatalogs(); ; vm.MyUsers = user.MyUserHierarchy(); //vm.MyUsers = vm.MyUsers != null ? vm.MyUsers.OrderBy(x => x.FullName()).ToList() : null; vm.Roles = ModelEnums.GetRoles().Where(r => r >= user.RoleId).ToArray(); vm.CatalogRoles = user.MyAssignableRoles(); vm.Catalog = catalog; vm.CatalogContents = catalog.Contents.OrderBy(c => c.Artist).ThenBy(c => c.Title).ToList(); UserEventLogService.LogUserEvent(UserActions.ViewCatalogDetail); if (!user.IsSuperAdmin()) { //vm.LookupCatalogs = vm.LookupCatalogs.LimitToAdministeredBy(user); } if (Request.IsAjaxRequest()) { return View(Views.ctrlDetail, vm); } else { return View(Views.Detail, vm); //return View(vm); } } catch (Exception ex) { Log.Error(ex); if (Request.IsAjaxRequest()) { throw ex; } else { this.FeedbackError("There was an error processing your request"); return RedirectToAction(Actions.Index()); } } }
public async Task<CatalogViewModel> GetCategoriesCatalogAsync(Specializations? specializations, string trainingProviderName) { var coursesQuery = GetCoursesQueryForSpecializations(specializations); var categoriesQuery = string.IsNullOrWhiteSpace(trainingProviderName) ? CatalogContext.Categories .Where(x => coursesQuery.Any(q => q.CategoryId == x.Id) && !x.IsDeleted) : CatalogContext.Categories .Where(x => x.TrainingProvider.Name == trainingProviderName && coursesQuery.Any(q => q.CategoryId == x.Id) && !x.IsDeleted); var catalog = await categoriesQuery .Select(x => new CatalogEntryViewModel { TrainingProvider = new TrainingProviderViewModel { Name = x.TrainingProvider.Name, LogoFileName = x.TrainingProvider.LogoFileName, SiteUrl = x.TrainingProvider.SiteUrl }, Title = x.Title, UrlName = x.UrlName, LogoFileName = x.LogoFileName, CourseCount = coursesQuery.Count(q => q.CategoryId == x.Id), LastCourseDate = coursesQuery .Where(q => q.CategoryId == x.Id) .OrderByDescending(d => d.ReleaseDate) .FirstOrDefault().ReleaseDate }) .OrderBy(x => x.Title) .ToListAsync(); if (!catalog.Any()) return null; var tokenCatalog = GetTokenCatalog(); var categoryCatalogViewModel = new CatalogViewModel { Navigation = new NavigationViewModel { SelectedToken = string.IsNullOrWhiteSpace(trainingProviderName) ? NavigationViewModel.ALLToken : trainingProviderName.ToTitleCaseInvariant(), TokenCatalog = tokenCatalog }, Categories = catalog }; return categoryCatalogViewModel; }
protected ActionResult ViewCategory(ProductCategory category) { if (category == null) { throw new ApplicationException("Category is null, be sure category is set before calling ViewCategory"); } /// get current catalog item List<TreeNode<ProductCategory>> categoryTree = CurrentStoreFrontOrThrow.CategoryTreeWhereActiveForCatalogByName(User.IsRegistered()); CatalogViewModel model = new CatalogViewModel(CurrentStoreFrontOrThrow, categoryTree, CurrentStoreFrontConfigOrThrow.CatalogPageInitialLevels, category, null, null, null); if (category.Theme != null) { ViewData.Theme(category.Theme); } return View("ViewCategory", this.LayoutNameForCatalog, model); }
// GET: Catalog public ActionResult Index() { CatalogViewModel model = new CatalogViewModel(CurrentStoreFrontOrThrow, CurrentStoreFrontOrThrow.CategoryTreeWhereActiveForCatalogList(User.IsRegistered()), CurrentStoreFrontConfigOrThrow.CatalogPageInitialLevels, null, null, null, null); return View("Index", this.LayoutNameForCatalog, model); }
protected ActionResult ViewProduct(Product product) { if (product == null) { throw new ApplicationException("Product is null, be sure product is set before calling ViewProduct"); } /// get current catalog item CatalogViewModel model = new CatalogViewModel(CurrentStoreFrontOrThrow, CurrentStoreFrontOrThrow.CategoryTreeWhereActiveForCatalogByName(User.IsRegistered()), CurrentStoreFrontConfigOrThrow.CatalogPageInitialLevels, product.Category, product, null, null); if (product.Theme != null) { ViewData.Theme(product.Theme); } else if (product.Category.Theme != null) { ViewData.Theme(product.Category.Theme); } return View("ViewProduct", this.LayoutNameForCatalog, model); }
// ************************************** // URL: /CatalogManagement/ // ************************************** public virtual ActionResult Index(int? id = null) { try { var vm = new CatalogViewModel(); vm.MyCatalogs = Account.User(false).MyAdminCatalogs();; vm.PageTitle = "Catalog Management"; vm.NavigationLocation = new string[] { "Admin" }; vm.ActiveUserId = Account.User().UserId; vm.CatalogContents = SearchService.GetLatestContent(Account.User(), id); return View(vm); } catch (Exception ex) { Log.Error(ex); this.FeedbackError("There was an error loading the Catalog Management page. Please try again in a bit."); return RedirectToAction(MVC.Home.Index()); } }