Example #1
0
        public IList <EntidadeCombo> GetAllAssuntoFraseCrista()
        {
            var listaAutorFraseCrista = new List <EntidadeCombo>();

            try
            {
                using (var conn = new SqlConnection(conSqlLocal))
                {
                    const string sql = "Select Id, Assunto from AssuntoFrase Order By Id";

                    conn.Open();
                    var cmd = new SqlCommand(sql, conn);
                    using (var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (reader.Read())
                        {
                            var livroBiblia = new EntidadeCombo
                            {
                                Id    = reader["Id"].ObjectToInt(),
                                Value = reader["Assunto"].ToString()
                            };

                            listaAutorFraseCrista.Add(livroBiblia);
                        }
                    }
                    return(listaAutorFraseCrista);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Example #2
0
        public IList <EntidadeCombo> GetAllAssuntoPorAutor(string idAutor)
        {
            var listaLivroBiblia = new List <EntidadeCombo>();

            using (var conn = new SqlConnection(conSqlLocal))
            {
                var sql = $@"Select Distinct assunto.Id IdAssunto, Assunto From FraseCrista fc
                            Join AutorFraseCrista autor on autor.Id = fc.IdAutorFraseCrista
                            Join AssuntoFrase assunto on assunto.Id = fc.IdAssuntoFrase
                            Where ({(string.IsNullOrEmpty(idAutor) ? "null" : idAutor)} Is Null Or
                            IdAutorFraseCrista = {(string.IsNullOrEmpty(idAutor) ? "null " : idAutor)})";
                try
                {
                    conn.Open();
                    var cmd = new SqlCommand(sql, conn);
                    using (var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (reader.Read())
                        {
                            var assuntosAutor = new EntidadeCombo
                            {
                                Id    = reader["IdAssunto"].ObjectToInt(),
                                Value = reader["Assunto"].ToString()
                            };

                            listaLivroBiblia.Add(assuntosAutor);
                        }
                    }
                    return(listaLivroBiblia);
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }