Esempio n. 1
0
 public ActionResult CreateCategory(Category category)
 {
     var manager = new AdminManager();
     var categoryCount = manager.GetAllCategories().Count;
     if (categoryCount == 0)
     {
         category.CategoryID = 1;
     }
     else
         category.CategoryID = manager.GetAllCategories().Count + 1;
     manager.AddCategory(category);
     return RedirectToAction("CategoryIndex", "Category");
 }
Esempio n. 2
0
        public void CanAddCategory()
        {
            var manager = new AdminManager();
            var toAdd = new Category();
            var count = manager.GetAllCategories().Count;

            toAdd.CategoryID = count + 1;
            toAdd.CategoryName = "TestCategory";

            manager.AddCategory(toAdd);

            var secondCount = manager.GetAllCategories().Count;
            Assert.AreEqual(count + 1, secondCount);
        }
Esempio n. 3
0
        public ActionResult CategoryIndex()
        {
            var manager = new AdminManager();
            var _categories = manager.GetAllCategories();

            return View(_categories);
        }
Esempio n. 4
0
        public void CancEditCategory()
        {
            var manager = new AdminManager();
            var toEdit = manager.GetCategoryByID(manager.GetAllCategories().Count);

            toEdit.CategoryName = "EditedCategory";
            manager.EditCategory(toEdit);

            var toCheck = manager.GetCategoryByID(manager.GetAllCategories().Count);
            Assert.AreEqual(toCheck.CategoryName,toEdit.CategoryName);
        }
Esempio n. 5
0
        public void CanDeleteCategory()
        {
            var manager = new AdminManager();
            var count = manager.GetAllCategories().Count;

            manager.DeleteCategory(count);

            var secondCount = manager.GetAllCategories().Count;
            Assert.AreEqual(count - 1, secondCount);
        }
 public IEnumerable<Category> Get()
 {
     var repo = new AdminManager();
     return repo.GetAllCategories();
 }