Exemplo n.º 1
0
 private void SetPacienteDeleteCommandOutputs(SqlCommand cmd, PacienteDeleteOutput output)
 {
     if (cmd.Parameters[1].Value != DBNull.Value)
     {
         output.ReturnValue = (PacienteDeleteOutput.Returns)cmd.Parameters[1].Value;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes single row from dbo.Paciente table by identity column.
        /// SQL+ Routine: dbo.PacienteDelete - Authored by IStrficek
        /// </summary>
        public PacienteDeleteOutput PacienteDelete(IPacienteDeleteInput input)
        {
            if (!input.IsValid())
            {
                throw new ArgumentException("PacienteDeleteInput fails validation - use the PacienteDeleteInput.IsValid() method prior to passing the input argument to the PacienteDelete method.", "input");
            }

            PacienteDeleteOutput output = new PacienteDeleteOutput();

            if (sqlConnection != null)
            {
                using (SqlCommand cmd = GetPacienteDeleteCommand(sqlConnection, input))
                {
                    cmd.Transaction = sqlTransaction;
                    PacienteDeleteCommand(cmd, output);
                }
                return(output);
            }
            for (int idx = 0; idx <= retryOptions.RetryIntervals.Count; idx++)
            {
                if (idx > 0)
                {
                    System.Threading.Thread.Sleep(retryOptions.RetryIntervals[idx - 1]);
                }
                try
                {
                    using (SqlConnection cnn = new SqlConnection(connectionString))
                        using (SqlCommand cmd = GetPacienteDeleteCommand(cnn, input))
                        {
                            cnn.Open();
                            PacienteDeleteCommand(cmd, output);
                            cnn.Close();
                        }
                    break;
                }
                catch (SqlException sqlException)
                {
                    bool throwException = true;

                    if (retryOptions.TransientErrorNumbers.Contains(sqlException.Number))
                    {
                        throwException = (idx == retryOptions.RetryIntervals.Count);

                        if (retryOptions.Logger != null)
                        {
                            retryOptions.Logger.Log(sqlException);
                        }
                    }
                    if (throwException)
                    {
                        throw;
                    }
                }
            }
            return(output);
        }
        public int DeletePaciente(Paciente paciente)
        {
            Service             service = GetService();
            PacienteDeleteInput input   = new PacienteDeleteInput()
            {
                IdPaciente = paciente.IdPaciente
            };
            PacienteDeleteOutput resultado = service.PacienteDelete(input);

            if (resultado.ReturnValue == PacienteDeleteOutput.Returns.Ok)
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }
Exemplo n.º 4
0
        private void PacienteDeleteCommand(SqlCommand cmd, PacienteDeleteOutput output)
        {
            cmd.ExecuteNonQuery();

            SetPacienteDeleteCommandOutputs(cmd, output);
        }