public async Task<Result> Create(Action<GlobalParameterCreateAction> action, CancellationToken cancellationToken = default) { cancellationToken.RequestCanceled(); var impl = new GlobalParameterCreateActionImpl(); action(impl); DefinedGlobalParameter definition = impl.Definition.Value; Debug.Assert(definition != null); var errors = new List<Error>(); if (string.IsNullOrWhiteSpace(definition.Name)) errors.Add(new ErrorImpl("The name of the parameter is missing.")); if (!impl.Errors.Value.IsNull()) errors.AddRange(impl.Errors.Value); if (errors.Any()) return new FaultedResult(errors); string url = $"api/global-parameters/{definition.Name}"; Result result = await Put(url, definition, cancellationToken); return result; }
public async Task <Result> CreateAsync(Action <GlobalParameterCreateAction> action, CancellationToken cancellationToken = new CancellationToken()) { cancellationToken.RequestCanceled(LogInfo); var impl = new GlobalParameterCreateActionImpl(); action(impl); DefinedGlobalParameter definition = impl.Definition.Value; if (string.IsNullOrWhiteSpace(definition.Name)) { throw new ParameterMissingException("The name of the parameter is missing."); } string url = $"api/global-parameters/{definition.Name}"; HttpResponseMessage response = await HttpPut(url, definition, cancellationToken); Result result = response.GetResponse(); LogInfo($"Sent request to RabbitMQ server to create a global parameter '{definition.Name}'."); return(result); }