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"); }
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); }
public ActionResult CategoryIndex() { var manager = new AdminManager(); var _categories = manager.GetAllCategories(); return View(_categories); }
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); }
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(); }