예제 #1
0
        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");
        }
예제 #2
0
        public void CanAddPost()
        {
            var manager = new AdminManager();
            var postCount = manager.GetAllPosts().Count;

            var toAdd = new Post();
            toAdd.PostCategory = new Category();

            toAdd.PostID = postCount + 1;
            toAdd.PostTitle = "Test Title";
            toAdd.PostBody = "Post body";
            toAdd.PostCategory.CategoryID = 1;
            toAdd.Status = ApprovalStatus.Approved;
            toAdd.PostDate = DateTime.Now;
            toAdd.PostTags = new List<Tag>();
            toAdd.User = new User();

            manager.AddPost(toAdd);

            var manager2 = new AdminManager();
            var postCount2 = manager2.GetAllPosts().Count;

            Assert.AreEqual(postCount + 1, postCount2);
        }
예제 #3
0
        public void CanDeletePost()
        {
            var manager = new AdminManager();
            var postCount = manager.GetAllPosts().Count;
            var toDelete = manager.GetPostByID(postCount);

            manager.DeletePost(toDelete);
            Assert.AreEqual(postCount - 1, manager.GetAllPosts().Count);
        }
예제 #4
0
 public void CancEditPost()
 {
     var manager = new AdminManager();
     var postToEdit = manager.GetPostByID(manager.GetAllPosts().Count);
     postToEdit.PostTitle = "EditedPostTitle";
     manager.EditPost(postToEdit);
     var editCheck = manager.GetPostByID(manager.GetAllPosts().Count);
     Assert.AreEqual(postToEdit.PostTitle,editCheck.PostTitle);
 }
예제 #5
0
 public ActionResult SubordinateIndex()
 {
     var manager = new AdminManager();
     var _posts = manager.GetAllPosts();
     return View(_posts);
 }