コード例 #1
0
 public async Task <IActionResult> Search(ProductListingViewModel model)
 {
     return(View(new ProductListingViewModel
     {
         Search = model.Search,
         Products = await this.products.SearchAsync(model.Search)
     }));
 }
コード例 #2
0
        public async Task <IViewComponentResult> InvokeAsync(int take)
        {
            var model = new ProductListingViewModel
            {
                Products = await this.productService.LatestProductsAsync(take)
            };

            return(View(model));
        }
コード例 #3
0
        public async Task <IActionResult> All(int page = 1)
        {
            var model = new ProductListingViewModel
            {
                Products      = await this.productService.AllProductsAsync(page),
                TotalProducts = await this.productService.TotalAsync(),
                CurrentPage   = page
            };

            return(View(model));
        }
コード例 #4
0
    public ActionResult Index()
    {
        var model = new ProductListingViewModel
        {
            Categories = new SelectList(new[]
            {
                new { Value = "1", Text = "category 1" },
                new { Value = "2", Text = "category 2" }
            }, "Value", "Text")
        };

        return(View(model));
    }
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: sky0193/wpf-tutorials
        protected override void OnStartup(StartupEventArgs e)
        {
            ProductStore productStore = new ProductStore();

            CreateProductViewModel  createProductViewModel  = new CreateProductViewModel(productStore);
            ProductListingViewModel productListingViewModel = new ProductListingViewModel(productStore);
            MainViewModel           mainViewModel           = new MainViewModel(createProductViewModel, productListingViewModel);

            MainWindow = new MainWindow()
            {
                DataContext = mainViewModel
            };
            MainWindow.Show();

            base.OnStartup(e);
        }
コード例 #6
0
        public ProductListingPage()
        {
            InitializeComponent();

            NavigationPage.SetHasBackButton(this, false);

            BindingContext = new ProductListingViewModel();
            //language
            if (App.lang == "ar-AE")
            {
                this.FlowDirection = FlowDirection.RightToLeft;
            }
            else
            {
                this.FlowDirection = FlowDirection.LeftToRight;
            }
        }
コード例 #7
0
        public ActionResult Index()
        {
            //try
            {
                var viewModel = new ProductListingViewModel();

                viewModel.Products = Mapper.Map <List <ProductViewModel> >(_productService.GetProducts());
                viewModel.Products.ForEach(p => p.Image = _pathUtilites.ToAbsolute(string.Format("~/img/Products/{0}.png", p.ArticleNr)));

                return(View(viewModel));
            }
            //catch(Exception exp)
            //{
            //    Logger.Error(exp);
            //}

            //return View();
        }
コード例 #8
0
        public async Task <IActionResult> Details(int id)
        {
            var product = await _productsService.FindProductAsync(id);

            var viewModel = new ProductListingViewModel(product)
            {
                Comments = await _commentService.GetCommentsFromProductAsync(id)
            };

            foreach (var comment in viewModel.Comments)
            {
                comment.Account = await _accountsService.FindAccountAsync(comment.AccountId);
            }

            if (TempData != null && (string)TempData["StatusMessage"] != "")
            {
                StatusMessage = (string)TempData["StatusMessage"];
            }

            return(View(viewModel));
        }
コード例 #9
0
        public ActionResult Index(string Category = null)
        {
            List <Product>         products;
            List <ProductCategory> categories = productCategories.Collection().ToList();

            if (Category == null)
            {
                products = context.Collection().ToList();
            }
            else
            {
                products = context.Collection().Where(p => p.Category == Category).ToList();
            }

            ProductListingViewModel productListingModel = new ProductListingViewModel();

            productListingModel.Product           = products;
            productListingModel.ProductCategories = categories;

            return(View(productListingModel));
        }
コード例 #10
0
        private ProductListingViewModel GetProductViewModelForQuickView(Product product, Sku sku)
        {
            if (sku != null)
            {
                var model = new ProductListingViewModel
                {
                    Url         = Url.ProductUrl(product),
                    Name        = product.Name,
                    FullName    = sku.Name,
                    ProductCode = sku.Code,
                    SkuId       = sku.Id,
                    Attributes  = sku.Attributes.ToDictionary(t => t.Key, t => t.Value),
                    IsNew       = sku.IsNew
                };
                if (sku.Images.Any())
                {
                    model.ImageAssetId = sku.Images.OrderBy(t => t.Order).FirstOrDefault().ImageAssetID;
                }

                return(model);
            }
            return(null);
        }
コード例 #11
0
 public ActionResult Index(ProductListingViewModel model)
 {
     return(View(model));
 }