private async Task HandleChapterAchievement(int userId, List <Achievement> achievementsForUser, Chapter chapter) { List <Chapter> chaptersForUser = await courseRepo.GetCompletedChaptersForUser(userId); if (!chaptersForUser.Contains(chapter)) { await InsertUserChapter(userId, chapter.ChapterId); Achievement achievementForChapterCount = await achievementService.GetAchievementForChapterCount(chaptersForUser.Count + 1); if (achievementForChapterCount != null && !achievementsForUser.Contains(achievementForChapterCount)) { await achievementService.InsertUserAchievement(userId, achievementForChapterCount.AchievementId); } } }