/// <summary> /// Modificará la fecha de renovación del demandante. Servirá para cuando el demandante decida renovar su estancia en el sistema. - /demandante/{dni}/fechaRenovacion /// </summary> /// <param name="entradaFechaRenovacion">String con la fecha de renovacion</param> /// <param name="Dni"></param> /// <param name="restkey"></param> /// <returns>MultipleDemandanteDniFechaRenovacionPut</returns> public IHttpActionResult PutByDniFechaRenovacion([FromBody] ServiciosRest.Demandantes.Models.EntradaFechaRenovacion entradaFechaRenovacion, [FromUri] string Dni, [FromUri] string restkey) { // TODO: implement PutByDniFechaRenovacion - route: demandante/{dni}/fechaRenovacion // var result = new MultipleDemandanteDniFechaRenovacionPut(); // return Ok(result); MultipleDemandanteDniFechaRenovacionPut resp = new MultipleDemandanteDniFechaRenovacionPut(); 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 = "UPDATE demandante SET fecha_renovacion=@fecha_renovacion " + "WHERE dni=@dni_demandante"; command.Prepare(); command.Parameters.AddWithValue("@fecha_renovacion", entradaFechaRenovacion.FechaRenovacion); command.Parameters.AddWithValue("@dni_demandante", Dni.ToString()); if (command.ExecuteNonQuery() > 0) { ResponseDemandante respuestaDemandante = new ResponseDemandante(); respuestaDemandante.Mensaje = "Se ha modificado la fecha de renovacion correctamente"; respuestaDemandante.Estado = true; return(Created("", respuestaDemandante)); } else { resp.ErrorDemandante = new ErrorDemandante(); resp.ErrorDemandante.Codigo = 400; resp.ErrorDemandante.Mensaje = "Error al modificar la fecha de renovacion"; return(Content(System.Net.HttpStatusCode.BadRequest, resp.ErrorDemandante)); } } catch (Exception e) { resp.ErrorDemandante = new ErrorDemandante(); resp.ErrorDemandante.Codigo = 400; resp.ErrorDemandante.Mensaje = "Error al modificar la fecha de renovacion: " + e.Message.ToString(); return(Content(System.Net.HttpStatusCode.BadRequest, resp.ErrorDemandante)); } finally { if (connection != null) { connection.Close(); } } }
public virtual IHttpActionResult PutByDniFechaRenovacionBase([FromBody] ServiciosRest.Demandantes.Models.EntradaFechaRenovacion entradaFechaRenovacion, [FromUri] string Dni, [FromUri] string restkey) { // Do not modify this code return(((IDemandanteController)this).PutByDniFechaRenovacion(entradaFechaRenovacion, Dni, restkey)); }