public void Insert(List<Friend> friends) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); foreach (var friend in friends) { try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); command.CommandText = "INSERT INTO Friends (id_vk) VALUES (\"" + friend.GetVkId() + "\")"; command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } dbMaster.CloseConnection(); }
public void Insert(List<String> groups) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); foreach (var group in groups) { try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); command.CommandText = "INSERT INTO Groups (id_vk) VALUES (\"" + group + "\")"; command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } dbMaster.CloseConnection(); }
public void Insert(List<ListFriends> listFriendses) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); foreach (var listFriends in listFriendses) { try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); command.CommandText = "INSERT INTO ListFriends (id_user, id_friend) " + "VALUES (" + listFriends.GetIdUser() + ", " + listFriends.GetIdFriend() + ")"; command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } dbMaster.CloseConnection(); }
public void Insert(int idFriend, List<Group> groups) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); foreach (var group in groups) { try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); command.CommandText = "INSERT INTO Groupsfriends (id_friend, id_group) " + "VALUES (" + idFriend + ", " + group.GetId() + ")"; command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } dbMaster.CloseConnection(); }
public void Insert(Top.Entity.Top top) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); foreach (var lineTop in top.GetDictionaryTops()) { command.CommandText = "INSERT INTO tops (id_group, count, data, id_user) " + "VALUES (" + lineTop.Key + ", " + lineTop.Value + ", DATE_FORMAT(CURRENT_DATE(), '%Y-%m-%d'), " + top.GetUserID() + ")"; command.ExecuteNonQuery(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } dbMaster.CloseConnection(); }