예제 #1
0
        public ActionResult Deactivate(int id)
        {
            var brepo = new BlogPostRepo();
            brepo.DeactivatePageById(id);

            return RedirectToAction("ManagePages", "Admin");
        }
예제 #2
0
        //[Authorize(Roles = "Admin")]
        public ActionResult Show(int id)
        {
            var brepo = new BlogPostRepo();
            var page = brepo.GetPageById(id);

            return View(page);
        }
예제 #3
0
        public ActionResult Edit(int id)
        {
            var brepo = new BlogPostRepo();
            var post = brepo.GetPageById(id);

            return View(post);
        }
예제 #4
0
 public ActionResult _StaticLinks()
 {
     var brepo = new BlogPostRepo();
     var list = brepo.GetAllStaticPages();
     //"~/Views/Shared/_StaticLinks"
     return PartialView(list);
 }
예제 #5
0
 public ActionResult AddStatic(StaticPage page)
 {
     var brepo = new BlogPostRepo();
     brepo.AddStaticPage(page);
     ViewBag.Message = "A new static page has been added.";
     return View("Success");
 }
예제 #6
0
        public ActionResult Index()
        {
            var repo = new BlogPostRepo();
            var list = repo.GetAllBlogPosts();

            return View(list);
        }
예제 #7
0
 public ActionResult Edit(StaticPage page)
 {
     var brepo = new BlogPostRepo();
     brepo.UpdatePage(page);
     ViewBag.Message = "The static page has been edited successfully.";
     return View("Success");
     //return RedirectToAction("ManagePages", "Admin");
 }
예제 #8
0
        public ActionResult Test()
        {
            // request by Matt
            BlogPostRepo repo = new BlogPostRepo();
            var blogs = repo.GetAllBlogPosts();

            return View(blogs);
        }
예제 #9
0
        public ActionResult ManagePages()
        {
            var pages = new List<StaticPage>();

            var repo = new BlogPostRepo();
            pages = repo.GetEveryStaticPageThatExists();

            return View(pages);
        }
예제 #10
0
        public void CanGetAllBlogPosts()
        {
            BlogPostRepo repo = new BlogPostRepo();

            var blogposts = repo.GetAllBlogPosts();

            var count = repo.GetBlogId();

            Assert.AreEqual(blogposts.Count, count);
        }
예제 #11
0
        public void CanGetBlogPostById()
        {
            BlogPostRepo repo = new BlogPostRepo();
            int testId1 = 1;
            int testId2 = 2;

            BlogPost blogpost1 = repo.GetBlogPostById(testId1);
            BlogPost blogpost2 = repo.GetBlogPostById(testId2);

            Assert.AreEqual(blogpost1.BlogID, testId1.ToString());
            Assert.AreEqual(blogpost2.BlogID, testId2.ToString());
        }
예제 #12
0
        public void CanEditBlogPost()
        {
            BlogPostRepo repo = new BlogPostRepo();

            BlogPost testPost = repo.GetBlogPostById(1);

            var titleBeforeEdited = testPost.Title;
            var titleAfterEdited = titleBeforeEdited + "UnitTest";

            testPost.Title = titleAfterEdited;

            repo.EditBlogPost(testPost);

            BlogPost resultPost = repo.GetBlogPostById(1);

            Assert.AreNotEqual(resultPost.Title, titleBeforeEdited);
            Assert.AreEqual(resultPost.Title, titleAfterEdited);
        }
예제 #13
0
        public void CanAddBlogPost()
        {
            BlogPostRepo repo = new BlogPostRepo();

            var posts = repo.GetAllBlogPosts();

            int preAddPostCount = posts.Count;

            BlogPost testPost = new BlogPost();
            testPost.Title = "Unit Test";
            testPost.DatePosted = DateTime.Now;
            testPost.Content = "Unit Test - CanAddBlogPost";

            repo.AddBlogPost(testPost);
            var postsAfterAdd = repo.GetAllBlogPosts();

            Assert.AreEqual(postsAfterAdd.Count, preAddPostCount + 1);
        }
예제 #14
0
 public ActionResult Unpublish(int ID)
 {
     var repo = new BlogPostRepo();
     repo.UnpublishPost(ID);
     return RedirectToAction("Index");
 }
예제 #15
0
        public void CanGetPageById()
        {
            BlogPostRepo repo = new BlogPostRepo();
            int testId = 2;

            var statePage = repo.GetPageById(testId);

            Assert.AreEqual(statePage.StaticPageID, testId);
        }