public async Task <IActionResult> Post(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "data/projectTypes")] ProjectTypeDocument projectType)
        {
            if (projectType is null)
            {
                throw new ArgumentNullException(nameof(projectType));
            }

            var newProjectType = await projectTypesRepository
                                 .AddAsync(projectType)
                                 .ConfigureAwait(false);

            return(new OkObjectResult(newProjectType));
        }
示例#2
0
        public async Task <ICommandResult> HandleAsync(OrchestratorProjectTypeCreateCommand orchestratorCommand, IDurableClient durableClient = null)
        {
            if (orchestratorCommand is null)
            {
                throw new ArgumentNullException(nameof(orchestratorCommand));
            }

            var commandResult = orchestratorCommand.CreateResult();

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

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

            return(commandResult);
        }