Song and the corresponding tables will be deleted if there are not song related to the tables. #44

This commit is contained in:
amazing-username
2019-05-25 00:50:30 +00:00
parent f9e66f416d
commit dd89b97997
6 changed files with 211 additions and 62 deletions
+26
View File
@@ -106,6 +106,32 @@ namespace Icarus.Models.Context
_logger.Error(msg, "An error occurred");
}
}
public void DeleteSong(Song song)
{
try
{
_logger.Info("Deleting song record");
using (var conn = GetConnection())
{
conn.Open();
var query = "DELETE FROM Song WHERE Id=@Id";
using (var cmd = new MySqlCommand(query, conn))
{
cmd.Parameters.AddWithValue("@Id", song.Id);
cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
var msg = ex.Message;
_logger.Error(msg, "An error occurred");
}
}
public void DeleteSong(int id)
{
try