public async Task <bool> AddUniqueAlertAsync <T>(T alert) where T : Alert { if (alert.NotificationId.HasValue) { var matchingAlert = await _alertRepository.GetAlertByNotificationIdAndTypeAsync <T>(alert.NotificationId.Value); if (matchingAlert != null) { return(false); } } await PopulateAndAddAlertAsync(alert); return(true); }