コード例 #1
0
 public void TestCreateBlog()
 {
     var operations = new BlogOperations(new MockRepo());
     var blogEntry = new BlogEntry();
     operations.CreateBlogEntry(blogEntry);
     Assert.AreEqual(6, operations.GetAllBlogEntries().Count);
 }
コード例 #2
0
 public void TestCreateStatic()
 {
     var operations = new BlogOperations(new MockRepo());
     var staticEntry = new StaticEntry();
     operations.CreateStaticEntry(staticEntry);
     Assert.AreEqual(4, operations.GetStaticEntries().Count);
 }
コード例 #3
0
        public ActionResult Create(BlogEntry blogEntry)
        {
            try
            {
                var blogOp = new BlogOperations();

                if (User.IsInRole("Admin"))
                {
                    blogEntry.StatusID = 1;
                }
                else
                {
                    blogEntry.StatusID = 3;
                }

                blogEntry.UserID = System.Web.HttpContext.Current.User.Identity.GetUserId();

                blogOp.CreateBlogEntry(blogEntry);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #4
0
ファイル: PRController.cs プロジェクト: timothylin/Blog
 // GET: PR
 public ActionResult PRDashboard()
 {
     _ops = new BlogOperations();
     var vm = new PRVM();
     vm.BlogPosts = _ops.GetAllBlogPosts().BlogPosts.OrderByDescending(p => p.TimeCreated).ToList();
     return View(vm);
 }
コード例 #5
0
 public void TestEditStatic()
 {
     var operations = new BlogOperations(new MockRepo());
     var staticEntry = operations.GetStaticEntry(2);
     staticEntry.StaticPageID = 2;
     staticEntry.Content = "edit";
     operations.EditStaticEntry(staticEntry);
     Assert.AreEqual("edit", operations.GetStaticEntry(2).Content);
 }
        public HttpResponseMessage Post(StaticEntry staticEntry)
        {
            var blogOp = new BlogOperations();
            blogOp.CreateStaticEntry(staticEntry);

            var response = Request.CreateResponse(HttpStatusCode.Created, staticEntry);

            return response;
        }
コード例 #7
0
        public HttpResponseMessage Put(BlogEntry blogEntry)
        {
            var blogOp = new BlogOperations();
            blogOp.EditBlogEntry(blogEntry);

            var response = Request.CreateResponse(HttpStatusCode.OK, blogEntry);

            return response;
        }
コード例 #8
0
        public HttpResponseMessage Delete(int id)
        {
            var blogOp = new BlogOperations();
            blogOp.DeleteBlogEntry(id);

            var response = Request.CreateResponse(HttpStatusCode.NoContent, id);

            return response;
        }
コード例 #9
0
 public void TestEditEntry()
 {
     var operations = new BlogOperations(new MockRepo());
     var blogEntry = operations.GetBlogEntry(1);
     blogEntry.BlogID = 1;
     blogEntry.PostContents = "edit";
     operations.EditBlogEntry(blogEntry);
     Assert.AreEqual("edit", operations.GetBlogEntry(1).PostContents);
 }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: timothylin/Blog
        public ActionResult Index()
        {
            _ops = new BlogOperations();
            var vm = new HomeVM();
            vm.BlogPosts = _ops.GetAllBlogPosts().BlogPosts.Where(p => p.Status == PageStatus.Approved).OrderByDescending(p => p.TimeCreated).ToList();
            vm.BlogStats = _ops.GetBlogStats().BlogStats;
            vm.Categories = _ops.GetAllCategories().Categories;

            return View(vm);
        }
コード例 #11
0
        public ActionResult CreateStatic(StaticEntry staticEntry)
        {
            try
            {
                var blogOp = new BlogOperations();

                blogOp.CreateStaticEntry(staticEntry);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #12
0
 public void TestGetBlog()
 {
     var operations = new BlogOperations(new MockRepo());
     var expected = new BlogEntry()
     {
         BlogID = 6,
         DateOfPost = DateTime.Now.Date,
         EndDate = DateTime.Now.Date.AddDays(2),
         StartDate = DateTime.Now.Date,
         Title = "Fake Title" + 6,
         PostContents = "Test Post" + 6,
         StatusID = 1,
         UserID = "19faea31-fb63-4d55-b661-6884255d4d53"
     };
     operations.CreateBlogEntry(expected);
     Assert.AreEqual(expected, operations.GetBlogEntry(6));
 }
コード例 #13
0
        public ActionResult Create(BlogEntry blogEntry)
        {
            try
            {
                var blogOp = new BlogOperations();

                if (User.IsInRole("Admin"))
                {
                    blogEntry.StatusID = 1;
                }
                else
                {
                    blogEntry.StatusID = 3;
                }

                blogOp.CreateBlogEntry(blogEntry);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #14
0
        // GET: Blog/Delete/5
        public ActionResult Delete(int id)
        {
            var blogOp = new BlogOperations();

            return View(blogOp.GetBlogEntry(id));
        }
コード例 #15
0
        // GET: Blog
        public ActionResult Index()
        {
            var blogOp = new BlogOperations();

            var fullblogs = blogOp.GetAllBlogEntries().Where(m => m.EndDate > DateTime.Now || m.EndDate.HasValue == false).ToList();

            //fullblogs.Count

            return View(fullblogs);
        }
コード例 #16
0
        //Create Get Static action, with partial view
        public PartialViewResult GetStaticPages()
        {
            var blogOp = new BlogOperations();
            var staticPages = blogOp.GetStaticEntries();

            return PartialView(staticPages);
        }
コード例 #17
0
        public ActionResult GetStaticPage(int id)
        {
            var blogOp = new BlogOperations();
            var getentry = blogOp.GetStaticEntry(id);

            return View(getentry);
        }
コード例 #18
0
 public void TestDeleteBlog()
 {
     var operations = new BlogOperations(new MockRepo());
     operations.DeleteBlogEntry(2);
     Assert.AreEqual(4, operations.GetAllBlogEntries().Count);
 }
コード例 #19
0
        //GET: Blog/EditStatic
        public ActionResult EditStatic(int id)
        {
            var blogOp = new BlogOperations();

            return View(blogOp.GetStaticEntry(id));
        }
コード例 #20
0
        public ActionResult Edit(int id, BlogEntry blogEntry)
        {
            try
            {
                var blogOp = new BlogOperations();
                blogOp.EditBlogEntry(blogEntry);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #21
0
        public ActionResult Blogs()
        {
            var operations = new BlogOperations();

            return View(operations.GetAllBlogEntries());
        }
コード例 #22
0
ファイル: BlogPostController.cs プロジェクト: timothylin/Blog
 public BlogPostController()
 {
     _ops = new BlogOperations();
     _jss = new JavaScriptSerializer();
 }
コード例 #23
0
        public List<StaticPage> Get()
        {
            _ops = new BlogOperations();

            return _ops.GetAllStaticPages().StaticPages.Where(p => p.Status == PageStatus.Approved).ToList();
        }
コード例 #24
0
        public void TestGetAllBlog()
        {
            var operations = new BlogOperations(new MockRepo());

            Assert.AreEqual(5, operations.GetAllBlogEntries().Count);
        }
コード例 #25
0
ファイル: BlogPostController.cs プロジェクト: timothylin/Blog
        public ActionResult AllPosts(int id)
        {
            _ops = new BlogOperations();
            var vM = new AllPostsVM();
            var allPosts = _ops.GetAllBlogPosts().BlogPosts.Where(p => p.Status == PageStatus.Approved).OrderByDescending(p => p.TimeCreated).ToList();
            vM.PostCount = allPosts.Count;
            vM.CurrentPage = id;
            vM.TotalPages = (int)Math.Ceiling((double)vM.PostCount/(double)5);

            if (id < vM.TotalPages)
            {
                for (int i = 5 * (id - 1); i < 5 * id; i++)
                {
                    vM.BlogPosts.Add(allPosts[i]);
                }
            }
            else if (id == vM.TotalPages)
            {
                for (int i = 5 * (id - 1); i < vM.PostCount; i++)
                {
                    vM.BlogPosts.Add(allPosts[i]);
                }
            }

            vM.Categories = _ops.GetAllCategories().Categories;

            return View("AllPosts", vM);
        }
コード例 #26
0
        public ActionResult Delete(int id, BlogEntry blogEntry)
        {
            try
            {
                var blogOp = new BlogOperations();
                blogOp.DeleteBlogEntry(id);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #27
0
        public ActionResult EditStatic(int id, StaticEntry staticEntry)
        {
            try
            {
                var blogOp = new BlogOperations();
                blogOp.EditStaticEntry(staticEntry);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #28
0
 public void TestDeleteStatic()
 {
     var operations = new BlogOperations(new MockRepo());
     operations.DeleteStaticEntry(2);
     Assert.AreEqual(2, operations.GetStaticEntries().Count);
 }
コード例 #29
0
        public StaticPage Get(int id)
        {
            _ops = new BlogOperations();

            return _ops.GetStaticPageById(id).StaticPage;
        }
コード例 #30
0
        public void TestGetStatic()
        {
            var operations = new BlogOperations(new MockRepo());
            var expected = new StaticEntry()
            {
                StaticPageID = 4,
                Content = "Fake Content" + 4,
                Title = "Fake Title" + 4,
                url = "/Fakeurl"
            };

            operations.CreateStaticEntry(expected);
            Assert.AreEqual(expected, operations.GetStaticEntry(4));
        }