private void SaveNotification(int challengeEntryId, ChallengeNotification challengeNotification) { using var serviceScope = Context.CreateScope(); var notificationPersistence = ServiceScopeHelper.GetService <NotificationPersistence>(serviceScope); var _ = notificationPersistence.AddToDb(challengeEntryId, challengeNotification); }
public async Task AddToDb(int challengeEntryId, ChallengeNotification challengeNotification) { var challengeNotificationToSave = challengeNotification with { ChallengeEntryId = challengeEntryId }; await _dbContext.Notifications.AddAsync(challengeNotificationToSave); await _dbContext.SaveChangesAsync(); } }