Пример #1
0
        /// <summary>
        /// Retorna todos os Datas
        /// throws BusinessData.BusinessLogic.DataAccess.DataAccessExceptiom
        /// </summary>
        /// <returns>Lista de Datas</returns>
        public List <Entities.Data> GetDatasByCalendario(Guid calendarioId)
        {
            DbCommand cmd = baseDados.GetStoredProcCommand("DatasSemestreSelectByCalendario");

            baseDados.AddInParameter(cmd, "@CalendarioId", DbType.Guid, calendarioId);

            Entities.Data        aux;
            List <Entities.Data> listaAux = new List <BusinessData.Entities.Data>();

            try
            {
                using (IDataReader leitor = baseDados.ExecuteReader(cmd))
                {
                    CategoriaDataDAO       categoriaDataDAO = new CategoriaDataDAO();
                    Entities.CategoriaData categoriaData    = null;
                    try
                    {
                        while (leitor.Read())
                        {
                            categoriaData = categoriaDataDAO.GetCategoriaData(leitor.GetGuid(leitor.GetOrdinal("CategoriasDataId")));

                            aux = Entities.Data.GetData(leitor.GetDateTime(leitor.GetOrdinal("Data")),
                                                        categoriaData);
                            listaAux.Add(aux);
                        }
                    }
                    catch (InvalidOperationException)
                    {
                        return(listaAux);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw new DataAccessException(ErroMessages.GetErrorMessage(ex.Number), ex);
            }

            return(listaAux);
        }
Пример #2
0
        /// <summary>
        /// Retorna todos os Datas 
        /// throws BusinessData.BusinessLogic.DataAccess.DataAccessExceptiom
        /// </summary>
        /// <returns>Lista de Datas</returns>
        public List<Entities.Data> GetDatasByCalendario(Guid calendarioId)
        {
            DbCommand cmd = baseDados.GetStoredProcCommand("DatasSemestreSelectByCalendario");
            baseDados.AddInParameter(cmd, "@CalendarioId", DbType.Guid, calendarioId);

            Entities.Data aux;
            List<Entities.Data> listaAux = new List<BusinessData.Entities.Data>();
            try
            {
                using (IDataReader leitor = baseDados.ExecuteReader(cmd))
                {

                    CategoriaDataDAO categoriaDataDAO = new CategoriaDataDAO();
                    Entities.CategoriaData categoriaData = null;
                    try
                    {
                        while (leitor.Read())
                        {
                            categoriaData = categoriaDataDAO.GetCategoriaData(leitor.GetGuid(leitor.GetOrdinal("CategoriasDataId")));

                            aux = Entities.Data.GetData(leitor.GetDateTime(leitor.GetOrdinal("Data")),
                                                        categoriaData);
                            listaAux.Add(aux);
                        }
                    }
                    catch (InvalidOperationException)
                    {
                        return listaAux;
                    }
                }
            }
            catch (SqlException ex)
            {
                throw new DataAccessException(ErroMessages.GetErrorMessage(ex.Number), ex);
            }

            return listaAux;
        }