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