public IActionResult Edit(Models.PesoCarrera model) { int result = 0; string response = ""; try { using (var db = new MySqlConnection(_connection)) { var sql = "UPDATE PesoCarrera SET IdCarrera=@IdCarrera, Peso=@Peso WHERE IdPeso=@IdPeso;"; result = db.Execute(sql, model); } if (result == 1) { response = "Se actualizo correctamente el peso de la carrera"; } else { response = "No se actualizo el peso"; } } catch (Exception e) { response = e.Message; } return(Ok(response)); }
public IActionResult Set(Models.PesoCarrera model) { int result = 0; string response = ""; try { using (var db = new MySqlConnection(_connection)) { var sql = "INSERT INTO PesoCarrera (IdCarrera, Peso) VALUES(@IdCarrera, @Peso)"; result = db.Execute(sql, model); } if (result == 1) { response = "El peso de la carrera se ha insertado correctamente"; } else { response = "No se inserto el peso"; } } catch (Exception e) { response = e.Message; } return(Ok(response)); }
public IActionResult Delete(Models.PesoCarrera model) { int result = 0; string response = ""; try { using (var db = new MySqlConnection(_connection)) { var sql = "DELETE FROM PesoCarrera WHERE IdPeso=@IdPeso;"; result = db.Execute(sql, model); } if (result == 1) { response = "Se elimino correctamente el peso de la carrera"; } else { response = "No se pudo eliminar el peso"; } } catch (Exception e) { response = e.Message; } return(Ok(response)); }