Exemplo n.º 1
0
        public async Task <UserDocument> RunActivity(
            [ActivityTrigger] IDurableActivityContext functionContext)
        {
            if (functionContext is null)
            {
                throw new ArgumentNullException(nameof(functionContext));
            }

            var(user, projectId) = functionContext.GetInput <(UserDocument, string)>();

            var membership = user.ProjectMembership(projectId);

            if (membership is null)
            {
                throw new InvalidOperationException($"User must contain a ProjectMembership for Project '{projectId}'");
            }

            user = await usersRepository
                   .AddProjectMembershipAsync(user, membership)
                   .ConfigureAwait(false);

            return(user);
        }