Пример #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();
            }
        }
Пример #2
0
        //
        // GET: /Post/Create
        public ActionResult Create()
        {
            Post post = new Post();

            return View(post);
        }
Пример #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();
            }
        }
Пример #4
0
        void IForumRepository.DeletePost(Post post)
        {
            forumDB.Posts.Remove(post);

            forumDB.SaveChanges();
        }
Пример #5
0
        void IForumRepository.AddPost(Post post)
        {
            forumDB.Posts.Add(post);

            forumDB.SaveChanges();
        }
Пример #6
0
        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();
        }