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); }