public void TestCreateBlog() { var operations = new BlogOperations(new MockRepo()); var blogEntry = new BlogEntry(); operations.CreateBlogEntry(blogEntry); Assert.AreEqual(6, operations.GetAllBlogEntries().Count); }
public void TestCreateStatic() { var operations = new BlogOperations(new MockRepo()); var staticEntry = new StaticEntry(); operations.CreateStaticEntry(staticEntry); Assert.AreEqual(4, operations.GetStaticEntries().Count); }
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(); } }
// 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); }
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; }
public HttpResponseMessage Put(BlogEntry blogEntry) { var blogOp = new BlogOperations(); blogOp.EditBlogEntry(blogEntry); var response = Request.CreateResponse(HttpStatusCode.OK, blogEntry); return response; }
public HttpResponseMessage Delete(int id) { var blogOp = new BlogOperations(); blogOp.DeleteBlogEntry(id); var response = Request.CreateResponse(HttpStatusCode.NoContent, id); return response; }
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); }
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); }
public ActionResult CreateStatic(StaticEntry staticEntry) { try { var blogOp = new BlogOperations(); blogOp.CreateStaticEntry(staticEntry); return RedirectToAction("Index"); } catch { return View(); } }
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)); }
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(); } }
// GET: Blog/Delete/5 public ActionResult Delete(int id) { var blogOp = new BlogOperations(); return View(blogOp.GetBlogEntry(id)); }
// 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); }
//Create Get Static action, with partial view public PartialViewResult GetStaticPages() { var blogOp = new BlogOperations(); var staticPages = blogOp.GetStaticEntries(); return PartialView(staticPages); }
public ActionResult GetStaticPage(int id) { var blogOp = new BlogOperations(); var getentry = blogOp.GetStaticEntry(id); return View(getentry); }
public void TestDeleteBlog() { var operations = new BlogOperations(new MockRepo()); operations.DeleteBlogEntry(2); Assert.AreEqual(4, operations.GetAllBlogEntries().Count); }
//GET: Blog/EditStatic public ActionResult EditStatic(int id) { var blogOp = new BlogOperations(); return View(blogOp.GetStaticEntry(id)); }
public ActionResult Edit(int id, BlogEntry blogEntry) { try { var blogOp = new BlogOperations(); blogOp.EditBlogEntry(blogEntry); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Blogs() { var operations = new BlogOperations(); return View(operations.GetAllBlogEntries()); }
public BlogPostController() { _ops = new BlogOperations(); _jss = new JavaScriptSerializer(); }
public List<StaticPage> Get() { _ops = new BlogOperations(); return _ops.GetAllStaticPages().StaticPages.Where(p => p.Status == PageStatus.Approved).ToList(); }
public void TestGetAllBlog() { var operations = new BlogOperations(new MockRepo()); Assert.AreEqual(5, operations.GetAllBlogEntries().Count); }
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); }
public ActionResult Delete(int id, BlogEntry blogEntry) { try { var blogOp = new BlogOperations(); blogOp.DeleteBlogEntry(id); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult EditStatic(int id, StaticEntry staticEntry) { try { var blogOp = new BlogOperations(); blogOp.EditStaticEntry(staticEntry); return RedirectToAction("Index"); } catch { return View(); } }
public void TestDeleteStatic() { var operations = new BlogOperations(new MockRepo()); operations.DeleteStaticEntry(2); Assert.AreEqual(2, operations.GetStaticEntries().Count); }
public StaticPage Get(int id) { _ops = new BlogOperations(); return _ops.GetStaticPageById(id).StaticPage; }
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)); }