protected void LinkbtnLixeiraBlog_Click(object sender, EventArgs e)
        {
            BlogDAO blogDAO = new BlogDAO();
            Blog    blog    = new Blog();

            PostDAO postDAO = new PostDAO();
            Post    post    = new Post();

            ComentarioDAO comentarioDAO = new ComentarioDAO();
            Comentario    comentario    = new Comentario();

            var list = postDAO.ObterPostsPorBlog(Convert.ToInt32(ddlListaBlogs.SelectedItem.Value));

            foreach (var item in list)
            {
                DeletarUmPost(item.id);
            }

            blog.id = Convert.ToInt32(ddlListaBlogs.SelectedItem.Value);
            blogDAO.DeletarUm(blog);
            blogDAO.Dispose();
            PopularListBlogs();
            PopularListPost();
            PopularLabelAutorPost();
            PopularLabelTemaPost();
            PopularLabelTextPost();
            lblBlogExcluido.Visible = true;
        }
        private void PopularLabelQtdBlogs()
        {
            BlogDAO       blogDAO       = new BlogDAO();
            BlogViewModel blogViewModel = new BlogViewModel();

            blogViewModel    = blogDAO.ObterResul();
            lblQntBlogs.Text = blogViewModel.qntBlogs.ToString();
            blogDAO.Dispose();
        }
        protected void LinkbtnDados_Click(object sender, EventArgs e)
        {
            BlogDAO blogDAO = new BlogDAO();
            var     list    = blogDAO.ObterBlogs();
            Class1  NOME    = new Class1();
            bool    retorno = NOME.GRAVAR(ref list);

            if (retorno)
            {
                lblExportado.Visible = true;
            }
            blogDAO.Dispose();
        }
        private void PopularLabelTemaPost()
        {
            BlogDAO blogDAO = new BlogDAO();

            try
            {
                var list = blogDAO.ObterBlogPorId(Convert.ToInt32(ddlListaBlogs.SelectedItem.Value));
                lblTemaBlog.Text = list.tema_blog;
            }
            catch (Exception)
            {
            }
            blogDAO.Dispose();
        }
        protected void btnCriar_Click(object sender, EventArgs e)
        {
            lblEmBranco.Visible      = false;
            lblPostCriado.Visible    = false;
            lblPostExistente.Visible = false;
            lblPostExcluido.Visible  = false;
            if (!string.IsNullOrWhiteSpace(txtNomeBlog.Text) && !string.IsNullOrWhiteSpace(txtTemaBlog.Text))
            {
                using (BlogDAO blogDAO = new BlogDAO())
                {
                    if (!blogDAO.ValidarBlog(txtNomeBlog.Text))
                    {
                        lblCampoBranco.Visible   = false;
                        lblBlogCriado.Visible    = true;
                        lblBlogExistente.Visible = false;
                        BlogDAO    blogs      = new BlogDAO();
                        UsuarioDAO usuarioDAO = new UsuarioDAO();

                        string  usuar   = Session["usuario"].ToString();
                        Usuario usuario = new Usuario();
                        usuario = usuarioDAO.ObterUsuarioPorLogin(usuar);

                        Blog blog = new Blog();
                        blog.nome_blog = txtNomeBlog.Text;
                        blog.id_user   = usuario.id;
                        blog.tema_blog = txtTemaBlog.Text;
                        blogs.Insert(blog);
                        blogs.Dispose();
                        usuarioDAO.Dispose();
                        txtNomeBlog.Text = "";
                        txtTemaBlog.Text = "";
                        PopularListBlogs();
                        PopularListPost();
                    }
                    else
                    {
                        lblBlogExistente.Visible = true;
                        lblCampoBranco.Visible   = false;
                        lblBlogCriado.Visible    = false;
                    }
                }
            }
            else
            {
                lblCampoBranco.Visible   = true;
                lblBlogExistente.Visible = false;
                lblBlogCriado.Visible    = false;
            }
        }
        private void PopularListBlogs()
        {
            BlogDAO blogDAO = new BlogDAO();
            var     list    = blogDAO.ObterBlogs();

            ddlListaBlogs.DataSource     = list;
            ddlListaBlogs.DataValueField = "id";
            ddlListaBlogs.DataTextField  = "nome_blog";
            ddlListaBlogs.DataBind();
            PopularLabelTemaPost();
            lblTextoPost.Visible = false;
            btnIrBlog.Visible    = true;
            TipoUser();
            blogDAO.Dispose();
            lblBlogExcluido.Visible = false;
            lblPostCriado.Visible   = false;
        }
        private void PopularLabelBlogs()
        {
            int     id_blogs = 0;
            int     id_post  = Convert.ToInt32(Session["post"]);
            PostDAO postDAO  = new PostDAO();
            var     lista    = postDAO.ObterTextoPorPost(id_post);

            lista.ForEach(item => id_blogs = item.id_blog);
            BlogDAO blogDAO = new BlogDAO();
            var     list    = blogDAO.ObterBlogPorId(id_blogs);

            lblTemaBlog.Text = list.tema_blog;
            var lis = blogDAO.ObterBlogPorId(id_blogs);

            lblNomeBlog.Text = lis.nome_blog;
            blogDAO.Dispose();
            postDAO.Dispose();
        }