示例#1
0
        /// <summary>
        /// proceso para inscribir un demandante de empleo en una oferta - /listaCandidatos
        /// </summary>
        /// <param name="datosListaCandidatos">Datos para lista candidatos</param>
        /// <returns>MultipleListaCandidatosPost</returns>
        public IHttpActionResult Post([FromBody] ServiciosRest.ListaCandidatos.Models.DatosListaCandidatos datosListaCandidatos)
        {
            // TODO: implement Post - route: listaCandidatos/listaCandidatos
            // var result = new MultipleListaCandidatosPost();
            // return Ok(result);
            MultipleListaCandidatosPost resp       = new MultipleListaCandidatosPost();
            MySqlConnection             connection = null;

            try
            {
                connection = new MySqlConnection("host=localhost; port=3306; user=usuario; password=; database=mtis_final");
                connection.Open();
                MySqlCommand command = new MySqlCommand();
                command.Connection  = connection;
                command.CommandText = "INSERT INTO lista_candidatos(id_oferta, dni_demandante, puntuacion) VALUES(@id_oferta, @dni_demandante, @puntuacion)";

                command.Prepare();
                command.Parameters.AddWithValue("@id_oferta", datosListaCandidatos.IdOferta);
                command.Parameters.AddWithValue("@dni_demandante", datosListaCandidatos.DniDemandante);
                command.Parameters.AddWithValue("@puntuacion", datosListaCandidatos.Puntuacion);
                command.ExecuteNonQuery();

                ResponseDatosListaCandidatos respuestaLista = new ResponseDatosListaCandidatos();
                respuestaLista.Mensaje = "Candidato añadido correctamente";
                respuestaLista.Estado  = true;
                return(Created("", respuestaLista));
            }

            catch (Exception e)
            {
                resp.ErrorDatosListaCandidatos         = new ErrorDatosListaCandidatos();
                resp.ErrorDatosListaCandidatos.Codigo  = 400;
                resp.ErrorDatosListaCandidatos.Mensaje = "No se ha podido añadir a lista" + e.Message.ToString();

                return(Content(System.Net.HttpStatusCode.BadRequest, resp.ErrorDatosListaCandidatos));
            }

            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
        }
示例#2
0
 public virtual IHttpActionResult PostBase([FromBody] ServiciosRest.ListaCandidatos.Models.DatosListaCandidatos datosListaCandidatos)
 {
     // Do not modify this code
     return(((IListaCandidatosController)this).Post(datosListaCandidatos));
 }