public async Task <IEnumerable <TeamDataEntity> > GetTeamDataEntitiesByIdsAsync( [ActivityTrigger] GetTeamDataEntitiesByIdsActivityDTO dto, ILogger log) { var teamDataEntities = await this.teamDataRepository.GetTeamDataEntitiesByIdsAsync(dto.TeamIds); // Analyzes the team id list used by a notification as recipients. // Find the teams in the list that do not exist in DB. // Log a warning message for each team that is absent in DB. foreach (var teamId in dto.TeamIds) { if (!teamDataEntities.Any(p => p.TeamId == teamId)) { var format = this.localizer.GetString("FailedToFindTeamInDbFormat"); var errorMessage = string.Format(format, teamId); log.LogWarning($"Notification {dto.NotificationDataEntityId}: {errorMessage}"); await this.notificationDataRepository.SaveWarningInNotificationDataEntityAsync( dto.NotificationDataEntityId, errorMessage); } } return(teamDataEntities); }
/// <summary> /// Run the activity. /// It retrieves team data entities by ids, i.e. Notification.Rosters or Notification.Teams. /// </summary> /// <param name="context">Durable orchestration context.</param> /// <param name="notificationDataEntityId">A notification data entity's ID.</param> /// <param name="teamIds">Team id list.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task <IEnumerable <TeamDataEntity> > RunAsync( IDurableOrchestrationContext context, string notificationDataEntityId, IEnumerable <string> teamIds) { if (teamIds == null || !teamIds.Any()) { throw new ArgumentException("Team id list is null or empty!"); } var dto = new GetTeamDataEntitiesByIdsActivityDTO { NotificationDataEntityId = notificationDataEntityId, TeamIds = teamIds, }; var teamDataEntityList = await context.CallActivityWithRetryAsync <IEnumerable <TeamDataEntity> >( nameof(GetTeamDataEntitiesByIdsActivity.GetTeamDataEntitiesByIdsAsync), ActivitySettings.CommonActivityRetryOptions, dto); return(teamDataEntityList); }