示例#1
0
        public CommandResponse AdicionarAgendamento(AgendamentoInfo obj)
        {
            try
            {
                _contexto.Connection.Open();
                _contexto.BeginTransaction();
                var query = AgendamentoInfoQueries.InsertAgendamentoInfo();

                var param = new DynamicParameters();
                param.Add(name: "IdProcesso", value: obj.IdProcesso.ToString(), direction: ParameterDirection.Input);
                if (obj.DataInicio != DateTime.MinValue)
                {
                    param.Add(name: "DataInicio", value: obj.DataInicio, direction: ParameterDirection.Input);
                }
                else
                {
                    param.Add(name: "DataInicio", value: null, direction: ParameterDirection.Input);
                }


                param.Add(name: "Descricao", value: obj.Descricao, direction: ParameterDirection.Input);
                param.Add(name: "NomeAgente", value: obj.NomeAgente, direction: ParameterDirection.Input);
                param.Add(name: "Periodicidade", value: obj.Periodicidade.ToString(), direction: ParameterDirection.Input);
                param.Add(name: "FrequenciaPeriodicidade", value: obj.FrequenciaPeriodicidade, direction: ParameterDirection.Input);
                param.Add(name: "StatusAgendamento", value: obj.StatusAgendamento.ToString(), direction: ParameterDirection.Input);
                param.Add(name: "HoraInicio", value: obj.HoraInicio.ToString(), direction: ParameterDirection.Input);
                param.Add(name: "MinutoInicio", value: obj.MinutoInicio.ToString(), direction: ParameterDirection.Input);
                param.Add(name: "AmPm", value: obj.AmPm, direction: ParameterDirection.Input);
                param.Add(name: "Ativo", value: obj.Ativo, direction: ParameterDirection.Input);
                param.Add(name: "DisparoManual", value: obj.DisparoManual, direction: ParameterDirection.Input);
                param.Add(name: "Path_UltimaExecucao", value: obj.MinutoInicio.ToString(), direction: ParameterDirection.Input);

                _contexto.Connection.Execute(query, param, _contexto.Transaction);

                query = EmailInfoQueries.InsertEmailInfoPorId();
                param = new DynamicParameters();
                param.Add(name: "IdProcesso", value: obj.IdProcesso.ToString(), direction: ParameterDirection.Input);
                param.Add(name: "Assunto", value: obj.Email.Assunto, direction: ParameterDirection.Input);
                param.Add(name: "Remetente", value: obj.Email.Remetente, direction: ParameterDirection.Input);
                param.Add(name: "Destinatario", value: obj.Email.Destinatario, direction: ParameterDirection.Input);
                param.Add(name: "Destinatario_CC", value: obj.Email.Destinatario_CC, direction: ParameterDirection.Input);
                param.Add(name: "Destinatario_CO", value: obj.Email.Destinatario_CO, direction: ParameterDirection.Input);
                _contexto.Connection.Execute(query, param, _contexto.Transaction);

                _contexto.Transaction.Commit();
                _contexto.Dispose();

                return(new CommandResponse(true, $"{obj.Descricao} adicionada com sucesso"));
            }
            catch (SQLiteException ex)
            {
                _contexto.Transaction.Rollback();
                _contexto.Dispose();
                return(new CommandResponse(false, $"{ex.Message}"));
            }
        }
示例#2
0
        public CommandResponse AtualizarCidade(Cidade cidade)
        {
            try
            {
                _context.Connection.Open();
                _context.BeginTransaction();

                _context.Connection.Execute(RegrasForunsQueries.UpdateCidade(cidade), _context.Transaction);
                _context.Connection.Execute(RegrasForunsQueries.UpdateApenasComarcaRegra(cidade.IdComarca, cidade.IdEstado, cidade.Id), _context.Transaction);
                _context.Connection.Execute(RegrasForunsQueries.UpdateApenasComarcaRegraBairro(cidade.IdComarca, cidade.IdEstado, cidade.Id), _context.Transaction);

                _context.Transaction.Commit();
                _context.Dispose();
                return(new CommandResponse(true, $"{cidade.Descricao} atualizada com sucesso"));
            }
            catch (SQLiteException ex)
            {
                _context.Transaction.Rollback();
                _context.Dispose();
                return(new CommandResponse(false, $"Erro : {ex.Message}"));
            }
        }