Hi Stephen, both 次 and 遍 can be used to describe the times an action happened, but there are still some differences between them. Using 次 more emphasizes that how many times the action happened. Such as 我去过两次北京。 and 给他送了两次礼物。 While 遍 emphasizes the whole action from the beginning to the end. Such as 这首歌我听了两遍。 and 我看了两遍这部电影。 Generally speaking, 次 lays the emphasis on the occurrence of an action as a whole event while 遍 on the process and thorough execution of an action.
HTH.