public ActionResult Create(Post post)
        {
            if (ModelState.IsValid)
            {
                db.Posts.Add(post);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(post);
        }
        public void Test_MakePost1ArgValid()
        {
            WebSecurity.Setup(w => w.CurrentUserId()).Returns(0);

            Post APost = new Post { UserID = 988 };
            Location ALocation = new Location { LocationID = 988 };
            PostLocationModel APlm = new PostLocationModel();
            APlm.Tpost = APost;
            APlm.Tlocation = ALocation;

            var result = Controller._MakePost(APlm) as JavaScriptResult;

            Assert.IsNotNull(result);
            Assert.IsTrue(SocialContext.Posts.Contains(APost));
            Assert.IsTrue(SocialContext.Locations.Contains(ALocation));
            Assert.AreEqual(result.Script, "$('#postcontainer').hide(); removeRadiusSelctor();"
                                       + "updateMarkers();");
        }
        public void Test_MakePost1ArgInValid()
        {
            Controller.ModelState.AddModelError("key", "Error.");
            WebSecurity.Setup(w => w.CurrentUserId()).Returns(0);

            Post APost = new Post { UserID = 988 };
            Location ALocation = new Location { LocationID = 988 };
            PostLocationModel APlm = new PostLocationModel();
            APlm.Tpost = APost;
            APlm.Tlocation = ALocation;

            var result = Controller._MakePost(APlm) as PartialViewResult;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.ViewBag.GroupList);

            foreach (Group g in result.ViewBag.TestingGroupList)
            {
                if (g.IsPrivate == true)
                {
                    //If a private group make sure they are an owner.
                    Assert.IsTrue(db.user0.Groups.Contains(g));
                }
                //Private group not an owner of.
                Assert.IsFalse(g.GroupID == 3);
            }

            Assert.AreEqual("_MakePost", result.ViewName);
        }
 public void Delete(Post post)
 {
     throw new NotImplementedException();
 }
 public void Add(Post post)
 {
     throw new NotImplementedException();
 }
 public ActionResult Edit(Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(post);
 }
 //Set up the posts.
 private void SetUpPosts()
 {
     post0 = new Post { PostID = 0, LocationID = 0, GroupID = 0, PostTitle = "See", VisibleProximity = 2000 };
     post1 = new Post { PostID = 1, LocationID = 0, GroupID = 1, PostTitle = "NotSee", VisibleProximity = 100 }; //Differentiating groups
     post2 = new Post { PostID = 2, LocationID = 1, GroupID = 2, PostTitle = "See", VisibleProximity = 3000 };
     post3 = new Post { PostID = 3, LocationID = 2, GroupID = 2, PostTitle = "NotSee", VisibleProximity = 2000 };
     post4 = new Post { PostID = 4, LocationID = 2, GroupID = 2, PostTitle = "See", VisibleProximity = 20000 };
 }
 public void Delete(Post post)
 {
     //Perhaps need to do the SQL to remove the blocks that users have on a post, not sure.
     db.Posts.Remove(post);
 }
 public void Add(Post post)
 {
     db.Posts.Add(post);
 }