Ejemplo n.º 1
0
        public async Task <ProjectDocument> RemoveAsync(ProjectDocument project)
        {
            if (project is null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            var container = await GetContainerAsync()
                            .ConfigureAwait(false);

            try
            {
                var response = await container
                               .DeleteItemAsync <ProjectDocument>(project.Id, new PartitionKey(Options.TenantName))
                               .ConfigureAwait(false);

                var tasks = new Task[]
                {
                    userRepository.RemoveProjectMembershipsAsync(project.Id),
                    projectLinkRepository.RemoveAsync(project.Id)
                };

                await Task
                .WhenAll(tasks)
                .ConfigureAwait(false);

                return(response.Resource);
            }
            catch (CosmosException cosmosEx) when(cosmosEx.StatusCode == HttpStatusCode.NotFound)
            {
                return(null); // already deleted
            }
        }
Ejemplo n.º 2
0
        public async Task <ICommandResult> HandleAsync(OrchestratorProjectLinkDeleteCommand orchestratorCommand)
        {
            var commandResult = orchestratorCommand.CreateResult();

            try
            {
                commandResult.Result = await projectLinkRepository
                                       .RemoveAsync(orchestratorCommand.Payload)
                                       .ConfigureAwait(false);

                commandResult.RuntimeStatus = CommandRuntimeStatus.Completed;
            }
            catch (Exception exc)
            {
                commandResult.Errors.Add(exc);
            }

            return(commandResult);
        }
        public async Task <ICommandResult> HandleAsync(OrchestratorProjectLinkDeleteCommand orchestratorCommand, IDurableClient durableClient = null)
        {
            if (orchestratorCommand is null)
            {
                throw new ArgumentNullException(nameof(orchestratorCommand));
            }

            var commandResult = orchestratorCommand.CreateResult();

            try
            {
                commandResult.Result = await projectLinkRepository
                                       .RemoveAsync(orchestratorCommand.Payload)
                                       .ConfigureAwait(false);

                commandResult.RuntimeStatus = CommandRuntimeStatus.Completed;
            }
            catch (Exception exc)
            {
                commandResult.Errors.Add(exc);
            }

            return(commandResult);
        }