Exemplo n.º 1
0
        public async Task <IActionResult> Delete(
            [HttpTrigger(AuthorizationLevel.Function, "delete", Route = "data/projectTypes/{projectTypeId}")] HttpRequest httpRequest, string projectTypeId)
        {
            if (httpRequest is null)
            {
                throw new ArgumentNullException(nameof(httpRequest));
            }

            if (projectTypeId is null)
            {
                throw new ArgumentNullException(nameof(projectTypeId));
            }

            var projectType = await projectTypesRepository
                              .GetAsync(projectTypeId)
                              .ConfigureAwait(false);

            if (projectType is null)
            {
                return(new NotFoundResult());
            }

            await projectTypesRepository
            .RemoveAsync(projectType)
            .ConfigureAwait(false);

            return(new OkObjectResult(projectType));
        }
Exemplo n.º 2
0
        public async Task <ICommandResult> HandleAsync(OrchestratorProjectTypeDeleteCommand orchestratorCommand, IDurableClient durableClient = null)
        {
            if (orchestratorCommand is null)
            {
                throw new ArgumentNullException(nameof(orchestratorCommand));
            }

            var commandResult = orchestratorCommand.CreateResult();

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

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

            return(commandResult);
        }