public ActionResult Edit(Post post)
        {
            post.Body = HttpUtility.HtmlDecode(post.Body);
            RepositoryFactory.PostRepository.UpdatePost(post);

            return RedirectToAction("Index", "Home", null);
        }
        public ActionResult Create(Post post, int categoryList)
        {
            post.Body = HttpUtility.HtmlDecode(post.Body);
            post.CategoryID = categoryList;
            RepositoryFactory.PostRepository.CreatePost(post);

            return RedirectToAction("Index", "Home", null);
        }
        public void VerifyPostProperties()
        {
            Post post = new Post
            {
                ID = 1,
                CategoryID = 1,
                Subject = "Subject",
                Body = "Body",
                CreatedBy = 1,
                CreatedOn = DateTime.Now,
                ModifiedBy = 1,
                ModifiedOn = DateTime.Now
            };

            Assert.IsNotNull(post);
        }
        public Post GetPostByID(int id)
        {
            const string sqlQuery = "SELECT ID, CategoryID, Subject, Body, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy " +
                                    "FROM Post " +
                                    "WHERE ID = @id";

            Post post = new Post();

            using (var reader = DbUtil.ExecuteReader(sqlQuery, new SQLiteParameter("@id", id)))
            {
                if (reader.Read())
                {
                    post = ReadPost(reader);
                }
            }

            return post;
        }
        public void UpdatePost(Post post)
        {
            const string sqlQuery = "UPDATE Post " +
                                    "SET CategoryID = @categoryID, " +
                                    "Subject = @subject, " +
                                    "Body = @body, " +
                                    "ModifiedOn = @modifiedOn, " +
                                    "ModifiedBy = @modifiedBy " +
                                    "WHERE ID = @id";
            List<SQLiteParameter> parameters = new List<SQLiteParameter>
            {
                new SQLiteParameter("@categoryID", post.CategoryID),
                new SQLiteParameter("@subject", post.Subject),
                new SQLiteParameter("@body", post.Body),
                new SQLiteParameter("modifiedOn", DateTime.Now),
                new SQLiteParameter("modifiedBy", post.ModifiedBy),
                new SQLiteParameter("@id", post.ID)
            };

            DbUtil.ExecuteNonQuery(sqlQuery, parameters.ToArray());
        }
        public void CreatePost(Post post)
        {
            const string sqlQuery = "INSERT INTO Post(CategoryID, Subject, Body, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy) " + 
                "VALUES (@categoryID, @subject, @body, @createdOn, @createdBy, @modifiedOn, @modifiedBy)";

            // Default to Admin if we don't have a user.
            if (post.CreatedBy == 0)
            {
                post.CreatedBy = 1;
            }

            List<SQLiteParameter> parameters = new List<SQLiteParameter>
            {
                new SQLiteParameter("@categoryID", post.CategoryID),
                new SQLiteParameter("@subject", post.Subject),
                new SQLiteParameter("@body", post.Body),
                new SQLiteParameter("createdOn", DateTime.Now),
                new SQLiteParameter("createdBy", post.CreatedBy),
                new SQLiteParameter("modifiedOn", DateTime.Now),
                new SQLiteParameter("modifiedBy", post.CreatedBy)
            };

            DbUtil.ExecuteNonQuery(sqlQuery, parameters.ToArray());
        }
        public ActionResult Delete(Post post)
        {
            RepositoryFactory.PostRepository.DeletePostByID(post.ID);

            return RedirectToAction("Index", "Home", null);
        }
 public void CreatePost(Post post)
 {
     return;
 }
 public void UpdatePost(Post post)
 {
     return;
 }