Esempio n. 1
0
 public ActionResult AddProduct()
 {
     var categoryRepo = new CategoryRepository(Properties.Settings.Default.ConStr);
     AddProductModelView model = new AddProductModelView();
     model.Categories = categoryRepo.GetCategories();
     return View(model);
 }
Esempio n. 2
0
 public ActionResult Product(int productId)
 {
     var productRepo = new ProductRepository(Properties.Settings.Default.ConStr);
     ProductPageViewModel model = new ProductPageViewModel();
     var categoryRepo = new CategoryRepository(Properties.Settings.Default.ConStr);
     model.Catergories = categoryRepo.GetCategories();
     model.Product = productRepo.GetProductWithImages(productId);
     return View(model);
 }
Esempio n. 3
0
        public ActionResult Index(int? categoryId, int? page)
        {
            IndexPageViewModel model = new IndexPageViewModel();
            if (categoryId == null)
            {
                categoryId = 1;
            }
            if (page == null)
            {
                page = 1;
            }

            var productRepo = new ProductRepository(Properties.Settings.Default.ConStr);
            var categoryRepo = new CategoryRepository(Properties.Settings.Default.ConStr);
            model.PageNumber = page.Value;
            model.CurrentCategory = categoryId.Value;
            model.Catergories = categoryRepo.GetCategories();
            model.Products = productRepo.GetProductsWithImage(categoryId.Value, page.Value);
            model.SetShowNextPage(productRepo.GetProductCountPerCategory(model.CurrentCategory));
            return View(model);
        }
Esempio n. 4
0
 public ActionResult AddCategory(Category category)
 {
     var repo = new CategoryRepository(Properties.Settings.Default.ConStr);
     repo.AddCategory(category);
     return Redirect("index");
 }