Пример #1
0
        public System.Collections.Generic.IEnumerable <Dominio.Entidades.OrgaoExpeditor> ObterTodos()
        {
            using (var cn = SqlDatabaseConnection.GetOpenConnectionGestaoCorp())
            {
                try
                {
                    var result = cn.Query <Dominio.Entidades.OrgaoExpeditor>(new OrgaoExpeditorSqlCommand().GetCommandSelectAll());

                    var sortedList = result
                                     .OrderBy(i => i.Nome == "Outros")
                                     .ThenBy(i => i.Nome == "MRE")
                                     .ThenBy(i => i.Nome == "MEX")
                                     .ThenBy(i => i.Nome == "MD")
                                     .ThenBy(i => i.Nome == "MAR")
                                     .ThenBy(i => i.Nome == "MAE")
                                     .ThenBy(i => i.Nome == "SSP")


                                     .ToList();
                    return(sortedList);
                }
                catch (System.Exception ex)
                {
                    throw new Exception(string.Concat("Erro ao obter orgão expeditor: ", ex.Message));
                }
            }
        }
Пример #2
0
 public IEnumerable <Dominio.Entidades.LogAcao> ObterTodosAcao()
 {
     try
     {
         using (var cn = SqlDatabaseConnection.GetOpenConnectionGestaoCorp())
         {
             return(cn.Query <Dominio.Entidades.LogAcao>(new LogAcaoSqlCommand().GetCommandSelectAll()));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao obter todas as ações do log: " + ex.Message);
     }
 }
Пример #3
0
 public IEnumerable <LogAcao> Filtrar(LogAcao acao)
 {
     try
     {
         using (var cn = SqlDatabaseConnection.GetOpenConnectionGestaoCorp())
         {
             return(cn.Query <Dominio.Entidades.LogAcao>(new LogAcaoSqlCommand().GetCommandFilter(acao)));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao filtrar logs: " + ex.Message);
     }
 }
Пример #4
0
 public LogAcao ObterAcaoPorId(int id)
 {
     try
     {
         using (var cn = SqlDatabaseConnection.GetOpenConnectionGestaoCorp())
         {
             return(cn.Query <Dominio.Entidades.LogAcao>(new LogAcaoSqlCommand().GetCommandSelectById(id)).FirstOrDefault());
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao obter ações por nome: " + ex.Message);
     }
 }
Пример #5
0
 public Dominio.Entidades.OrgaoExpeditor ObterOrgaoExpeditorPorId(string id)
 {
     using (var cn = SqlDatabaseConnection.GetOpenConnectionGestaoCorp())
     {
         try
         {
             return(cn.Query <Dominio.Entidades.OrgaoExpeditor>(new OrgaoExpeditorSqlCommand().GetCommandSelectById(id)).FirstOrDefault());
         }
         catch (System.Exception ex)
         {
             throw new Exception(string.Concat("Erro ao obter orgão expeditor: ", ex.Message));
         }
     }
 }
Пример #6
0
        public IEnumerable <Dominio.Entidades.Log> Filtrar(Dominio.Entidades.Log log)
        {
            try
            {
                using (var cn = SqlDatabaseConnection.GetOpenConnectionGestaoCorp())
                {
                    var resultLog = cn.Query <Dominio.Entidades.Log>(new LogSqlCommand().GetCommandFilter(log));

                    foreach (var l in resultLog.Where(s => s.Id == log.Id))
                    {
                        l.cLogCampos = cn.Query <Dominio.Entidades.LogCamposAlterados>(new LogSqlCommand().GetCommandCamposAlteradosByIdLog(log.Id)).ToList();
                    }
                    return(resultLog);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao filtrar logs: " + ex.Message);
            }
        }
Пример #7
0
        public Dominio.Entidades.Log Adicionar(Dominio.Entidades.Log log)
        {
            try
            {
                using (var cn = SqlDatabaseConnection.GetOpenConnectionGestaoCorp())
                {
                    log.Id = cn.Query <int>(new LogSqlCommand().GetCommandInsert(log)).Single <int>();

                    foreach (var campo in log.cLogCampos)
                    {
                        campo.IdLog = log.Id;
                        cn.Query <int>(new LogSqlCommand().GetCommandInsertCamposAlterados(campo)).Single <int>();
                    }

                    return(log);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao gerar Log: " + ex.Message);
            }
        }