public ActionResult EditCategory(int id)
        {
            var manager = new AdminManager();
            var category = manager.GetCategoryByID(id);

            return View(category);
        }
        public ActionResult EditPost(Post post)
        {
            //if (ModelState.IsValid)
            {
                var manager = new AdminManager();
                post.PostDate = DateTime.Now;
                post.PostCategory.CategoryName = manager.GetCategoryByID(post.PostCategory.CategoryID).CategoryName;
                manager.EditPost(post);

            }
            return RedirectToAction("Index", "Home");
        }
        public ActionResult CreatePost(Post post)
        {
            var manager = new AdminManager();
            var postCount = manager.GetAllPosts().Count;
            post.PostCategory.CategoryName = manager.GetCategoryByID(post.PostCategory.CategoryID).CategoryName;

            post.PostDate = DateTime.Now;
            post.Status = ApprovalStatus.Pending;
            if (postCount == 0)
            {
                post.PostID = 1;
            }
            else
                post.PostID = manager.GetAllPosts().Count + 1;
            manager.AddPost(post);
            return RedirectToAction("SubordinateIndex", "Subordinate");
        }
Exemple #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);
        }
Exemple #5
0
 public void CanGetCategoryById()
 {
     var manager = new AdminManager();
     var category = manager.GetCategoryByID(1);
     Assert.AreEqual(category.CategoryID, 1);
 }
 public Category Get(int id)
 {
     var repo = new AdminManager();
     return repo.GetCategoryByID(id);
 }