Пример #1
0
        public ActionResult Product(int productId)
        {
            ProductViewModel viewModel = new ProductViewModel();
            ProductCategoryRepository repo = new ProductCategoryRepository(Properties.Settings.Default.ConStr);
            viewModel.product = repo.GetProductById(productId);
            viewModel.Categories = repo.GetCategories();

            return View(viewModel);
        }
Пример #2
0
 public ActionResult Index(int? categoryId)
 {
     if(categoryId == null)
     {
         categoryId = 1;
     }
     IndexViewModel viewModel = new IndexViewModel();
     ProductCategoryRepository repo = new ProductCategoryRepository(Properties.Settings.Default.ConStr);
     viewModel.Categories = repo.GetCategories();
     viewModel.Products = repo.GetProcuctsByCategory(categoryId);
     viewModel.Id = categoryId;
     return View(viewModel);
 }