Exemple #1
0
        public void Ataulizar(TblAutor autor)
        {
            try
            {
                using (ContextBlog con = new ContextBlog())
                {
                    con.Entry(autor).State = EntityState.Modified;

                    if (string.IsNullOrEmpty(autor.Foto))
                    {
                        con.Entry(autor).Property(p => p.Foto).IsModified = false;
                    }

                    con.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public void Ataulizar(TblPost categoria)
        {
            try
            {
                using (ContextBlog con = new ContextBlog())
                {
                    con.Entry(categoria).State = EntityState.Modified;

                    con.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        public void Excluir(TblPost categoria)
        {
            try
            {
                using (ContextBlog con = new ContextBlog())
                {
                    con.Entry(categoria).State = categoria.Id == 0 ?
                                                 EntityState.Added :
                                                 EntityState.Deleted;

                    con.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #4
0
        public void Excluir(TblAutor autor)
        {
            try
            {
                using (ContextBlog con = new ContextBlog())
                {
                    con.Entry(autor).State = autor.Id == 0 ?
                                             EntityState.Added :
                                             EntityState.Deleted;

                    con.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }