/// <summary> /// add a user project to db /// </summary> /// <param name="userProject"></param> public void addUserProject(UserProject userProject) { using (MySqlConnection conn = GetConnection()) { conn.Open(); string sqlCmd = "INSERT INTO UserProject(UserId, GroupId) VALUES (@UserId, @GroupId);"; using (MySqlCommand cmd = new MySqlCommand(sqlCmd, conn)) { cmd.Parameters.AddWithValue("@UserId", userProject.UserId); cmd.Parameters.AddWithValue("@GroupId", userProject.GroupId); cmd.ExecuteNonQuery(); } } }
/// <summary> /// update user project in db /// </summary> /// <param name="userProject">userProject to update with updated fields</param> public void updateUserProject(UserProject userProject) { using (MySqlConnection conn = GetConnection()) { conn.Open(); string sqlCmd = "UPDATE UserProject SET UserId = @UserId, GroupId = @GroupId WHERE UserProjectId = @UserProjectId;"; using (MySqlCommand cmd = new MySqlCommand(sqlCmd, conn)) { cmd.Parameters.AddWithValue("@UserId", userProject.UserId); cmd.Parameters.AddWithValue("@GroupId", userProject.GroupId); cmd.Parameters.AddWithValue("@UserProjectId", userProject.UserProjectId); cmd.ExecuteNonQuery(); } } }