Exemplo n.º 1
0
        public async Task <Result> Create(Action <VirtualHostCreateAction> action, CancellationToken cancellationToken = default)
        {
            cancellationToken.RequestCanceled();

            var impl = new VirtualHostCreateActionImpl();

            action(impl);

            impl.Validate();

            VirtualHostDefinition definition = impl.Definition.Value;

            string url = $"api/vhosts/{impl.VirtualHostName.Value.ToSanitizedName()}";

            if (impl.Errors.Value.Any())
            {
                return(new FaultedResult(impl.Errors.Value, new DebugInfoImpl(url, definition.ToJsonString(Deserializer.Options))));
            }

            return(await Put(url, definition, cancellationToken).ConfigureAwait(false));
        }