Beispiel #1
0
 public LiberarRecursoComponente_Response LiberarRecursoComponente(LiberarRecursoComponente_Request obj)
 {
     try
     {
         return(liberarBL.LiberarRecursoComponente(obj));
     }
     catch (Exception)
     {
         throw;
     }
 }
        public LiberarRecursoComponente_Response LiberarRecursoComponente(LiberarRecursoComponente_Request entidad)
        {
            LiberarRecursoComponente_Response retorno = new LiberarRecursoComponente_Response();

            try
            {
                using (SqlConnection conection = new SqlConnection(ConfigurationManager.ConnectionStrings["cnxIndra"].ConnectionString))
                {
                    conection.Open();

                    using (SqlCommand command = new SqlCommand("[pa_spt_portafolio_liberar_recurso]", conection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@nid_portafolio", entidad.nid_portafolio);
                        command.Parameters.AddWithValue("@nid_componente", entidad.nid_componente);
                        command.Parameters.AddWithValue("@nid_recurso", entidad.nid_recurso);
                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            if (dr.HasRows)
                            {
                                while (dr.Read())
                                {
                                    if ((dr.GetInt32(dr.GetOrdinal("nid_retorno")) > 0))
                                    {
                                        retorno.respuesta   = 1;
                                        retorno.str_mensaje = "";
                                    }
                                    else
                                    {
                                        retorno.respuesta   = 0;
                                        retorno.str_mensaje = "No se pudo liberar el componente, debido a que el componentes esta en ejecución";
                                    }
                                }
                            }
                        }
                    }
                    conection.Close();
                }
                return(retorno);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }