public void Test1() { Blog blog = new Blog(); BlogDataAccess objBlog = new BlogDataAccess(); //IEnumerable<Blog> allBlogs = objBlog.GetAllBlogs(); int maxid = 40; if (maxid != 0) { blog.Id = maxid + 1; } else { blog.Id = 1; } blog.Subject = "Random"; blog.Description = "Test Description"; blog.BlogEntry = "<div></div>"; blog.Pseudonym = "Prajith"; blog.Image = Guid.NewGuid(); blog.DateInserted = DateTime.Now; int ret = objBlog.AddBlog(blog); Assert.AreEqual(1, ret); }
public IActionResult Index(int pageIndex = 1, int pageRows = 5) { List <BlogViewModel> blogs = new List <BlogViewModel>(); int count = 0; int total = 0; int currentPageIndex = 0; int firstPage = 0; int lastPage = 0; int previous = 0; int next = 0; blogs = BlogDataAccess.GetBlogs(out count, out total, pageIndex, pageRows); PageUtility.BuildPageParameters(out previous, out next, out currentPageIndex, out firstPage, out lastPage, pageIndex, count); string pageUrl = @"/Blog/Index?pageIndex={0}&pageRows={1}"; string firstPageUrl = string.Format(pageUrl, firstPage, pageRows); string lastPageUrl = string.Format(pageUrl, lastPage, pageRows); string previousPageUrl = string.Format(pageUrl, previous, pageRows); string nextPageUrl = string.Format(pageUrl, next, pageRows); ViewBag.Blogs = blogs; ViewBag.Count = count; ViewBag.Total = total; ViewBag.PageIndex = currentPageIndex; ViewBag.FirstPageUrl = firstPageUrl; ViewBag.LastPageUrl = lastPageUrl; ViewBag.PreviousPageUrl = previousPageUrl; ViewBag.NextPageUrl = nextPageUrl; return(View()); }
public IActionResult Index() { int blogCount = 0; int blogTypeCount = 0; blogCount = BlogDataAccess.GetBlogCount(); blogTypeCount = BlogTypeDataAccess.GetBlogTypeCount(); ViewBag.BlogCount = blogCount; ViewBag.BlogTypeCount = blogTypeCount; return(View()); }