public bool insertaPokemonFavorito(PokeFav z) { IDbTransaction dbTransaction; DynamicParameters parameters = new DynamicParameters(); parameters.Add("@id_pokemon", z.id_Pokemon); parameters.Add("@name", z.name); parameters.Add("@img", z.img); using (IDbConnection db = GetConnection()) { db.Open(); dbTransaction = db.BeginTransaction(); try { db.ExecuteScalar("uspInsertPokeFav", commandType: CommandType.StoredProcedure, param: parameters, transaction: dbTransaction); dbTransaction.Commit(); db.Close(); return(true); } catch (Exception) { dbTransaction.Rollback(); db.Close(); return(false); } } }
public IActionResult Post([FromBody] PokeFav pokemon) { try { return(Ok(_fav.insertaPokemonFavorito(pokemon))); } catch (Exception ex) { return(StatusCode(500, ex)); } }