public async Task <OpenApiResult> CreateNotificationsAsync( IOpenApiContext context, CreateNotificationsRequest body) { // We can guarantee tenant Id is available because it's part of the Uri. ITenant tenant = await this.marainServicesTenancy.GetRequestingTenantAsync(context.CurrentTenantId !).ConfigureAwait(false); string delegatedTenantId = await this.marainServicesTenancy.GetDelegatedTenantIdForRequestingTenantAsync(tenant.Id).ConfigureAwait(false); var operationId = Guid.NewGuid(); CreateOperationHeaders response = await this.operationsControlClient.CreateOperationAsync( delegatedTenantId, operationId).ConfigureAwait(false); // Create a new CreateNotificationForDeliveryChannelsRequest Object which supports the communication types and delivery channels var createNotificationForDeliveryChannelsRequestObject = new CreateNotificationForDeliveryChannelsRequest( body.NotificationType, body.UserIds, body.Timestamp, body.Properties, body.CorrelationIds); IDurableOrchestrationClient orchestrationClient = context.AsDurableFunctionsOpenApiContext().OrchestrationClient ?? throw new OpenApiServiceMismatchException($"Operation {CreateNotificationsOperationId} has been invoked, but no Durable Orchestration Client is available on the OpenApi context."); await orchestrationClient.StartNewAsync( nameof(CreateAndDispatchNotificationsOrchestration), new TenantedFunctionData <CreateNotificationForDeliveryChannelsRequest>(context.CurrentTenantId !, createNotificationForDeliveryChannelsRequestObject, operationId)).ConfigureAwait(false); return(this.AcceptedResult(response.Location)); }
public async Task <OpenApiResult> UpdateReadStatusesAsync( IOpenApiContext context, BatchReadStatusUpdateRequestItem[] body) { // We can guarantee tenant Id is available because it's part of the Uri. ITenant tenant = await this.marainServicesTenancy.GetRequestingTenantAsync(context.CurrentTenantId !).ConfigureAwait(false); string delegatedTenantId = await this.marainServicesTenancy.GetDelegatedTenantIdForRequestingTenantAsync(tenant.Id).ConfigureAwait(false); var operationId = Guid.NewGuid(); CreateOperationHeaders response = await this.operationsControlClient.CreateOperationAsync( delegatedTenantId, operationId).ConfigureAwait(false); IDurableOrchestrationClient orchestrationClient = context.AsDurableFunctionsOpenApiContext().OrchestrationClient ?? throw new OpenApiServiceMismatchException($"Operation {BatchReadStatusUpdateOperationId} has been invoked, but no Durable Orchestration Client is available on the OpenApi context."); await orchestrationClient.StartNewAsync( nameof(UpdateNotificationReadStatusesOrchestration), new TenantedFunctionData <BatchReadStatusUpdateRequestItem[]>(context.CurrentTenantId !, body, operationId)).ConfigureAwait(false); return(this.AcceptedResult(response.Location)); }