Ejemplo n.º 1
0
        /// <summary>
        /// Updates post, using the id
        /// </summary>
        /// <param name="id">Id of the Post to update</param>
        /// <returns>Return true if update is successfull, else return false </returns>
        static public bool UpdatePost(Post post)
        {
            bool operationSuccess = false;

            if (post != null && ValidatePost(post))
            {
                SqlPostData sql = new SqlPostData();
                sql.Update(post);
                operationSuccess = true;
            }
            return(operationSuccess);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes post
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Returns true if sucessfull, else returns false</returns>
        static public bool DeletePost(Post post)
        {
            bool operationSucess = false;

            if (post != null)
            {
                SqlPostData sql = new SqlPostData();
                sql.Remove(post.Id);
                operationSucess = true;
            }
            return(operationSucess);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a validated post
        /// </summary>
        /// <param name="post"></param>
        /// <returns>Return true if add is successfull, else return false</returns>
        static public bool AddPost(Post post)
        {
            bool operationSuccess = false;

            if (post != null && ValidatePost(post))
            {
                //ASIGNAMOS FECHA
                post.Fecha = DateTime.Now;
                //post.Imagen = "";
                //post.Categoria = "";
                SqlPostData sql = new SqlPostData();
                sql.Add(post);
                operationSuccess = true;
            }
            return(operationSuccess);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets all the posts
        /// </summary>
        /// <returns>IEnumerable of Post</returns>
        static public IEnumerable <Post> GetAllPost()
        {
            SqlPostData sql = new SqlPostData();

            return(sql.GetAll().Where(x => x.IsActive == true).OrderByDescending(x => x.Fecha));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a post
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Return post if found, else null</returns>
        static public Post GetPost(int id)
        {
            SqlPostData sql = new SqlPostData();

            return(sql.Get(id));
        }