internal static Renting getRentingByUser(string id) { query = $"SELECT * FROM renting WHERE IDUser = '******';"; Renting renting = null; using (var connection = new NpgsqlConnection(AppSettingProvider.connString)) { connection.Open(); renting = connection.Query <Renting>(query).FirstOrDefault(); } return(renting); }
internal static void updateRenting(Renting renting) { query = "UPDATE renting SET " + $"date_to = '{renting.date_to}' " + $"WHERE ID_Renting = '{renting.ID_Renting}';"; var id = -1; using (var connection = new NpgsqlConnection(AppSettingProvider.connString)) { connection.Open(); id = connection.ExecuteScalar <int>(query, renting); } }
internal static async Task <int> createRenting(Renting renting) { query = "INSERT INTO renting " + "(IDAp, IDUser, date_from, date_to) " + "VALUES " + $"({renting.IDAp}, '{renting.IDUser}', '{renting.date_from}', '{renting.date_to}') " + "RETURNING ID_Renting;"; int id = -1; using (var connection = new NpgsqlConnection(AppSettingProvider.connString)) { connection.Open(); id = await connection.ExecuteScalarAsync <int>(query, renting); } return(id); }