예제 #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 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();
            }
        }
        public HttpResponseMessage Post(BlogEntry blogEntry)
        {
            var blogOp = new BlogOperations();
            blogOp.CreateBlogEntry(blogEntry);

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

            return response;
        }
        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();
            }
        }
예제 #5
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));
 }