Beispiel #1
0
        public ActionResult Create(Post post)
        {
            try
            {
                // TODO: Add insert logic here

                IForumRepository tmpRep = new SQLForumRepository();

                tmpRep.AddPost(post);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Beispiel #2
0
        //
        // GET: /Post/Create
        public ActionResult Create()
        {
            Post post = new Post();

            return View(post);
        }
Beispiel #3
0
        public ActionResult Edit(int id, Post post)
        {
            try
            {
                // TODO: Add update logic here

                IForumRepository tmpRep = new SQLForumRepository();

                tmpRep.UpdatePost(post);

                return RedirectToAction("Index");

            }
            catch
            {
                return View();
            }
        }
        void IForumRepository.DeletePost(Post post)
        {
            forumDB.Posts.Remove(post);

            forumDB.SaveChanges();
        }
        void IForumRepository.AddPost(Post post)
        {
            forumDB.Posts.Add(post);

            forumDB.SaveChanges();
        }
        void IForumRepository.UpdatePost(Post post)
        {
            var tmpPost = forumDB.Posts.Single(p => p.PostID == post.PostID);

            tmpPost.PostBody = post.PostBody;
            tmpPost.PostDateTime = post.PostDateTime;
            tmpPost.PostTitle = post.PostTitle;
            tmpPost.ThreadID = post.ThreadID;
            tmpPost.UserID = post.UserID;

            forumDB.SaveChanges();
        }