예제 #1
0
        public Task <Result> Delete(Action <UserDeleteAction> action, CancellationToken cancellationToken = default)
        {
            cancellationToken.RequestCanceled();

            var impl = new UserDeleteActionImpl();

            action(impl);

            impl.Validate();

            string url = $"api/users/{impl.Username}";

            if (impl.Errors.Value.Any())
            {
                return(Task.FromResult <Result>(new FaultedResult(impl.Errors.Value, new DebugInfoImpl(url))));
            }

            return(Delete(url, cancellationToken));
        }
예제 #2
0
        public async Task <Result> Delete(Action <UserDeleteAction> action, CancellationToken cancellationToken = default)
        {
            cancellationToken.RequestCanceled();

            var impl = new UserDeleteActionImpl();

            action(impl);

            if (string.IsNullOrWhiteSpace(impl.Username))
            {
                return(new FaultedResult(new List <Error> {
                    new ErrorImpl("The username is missing.")
                }));
            }

            string url = $"api/users/{impl.Username}";

            Result result = await Delete(url, cancellationToken);

            return(result);
        }
예제 #3
0
        public async Task <Result> DeleteAsync(Action <UserDeleteAction> action, CancellationToken cancellationToken = new CancellationToken())
        {
            cancellationToken.RequestCanceled(LogInfo);

            var impl = new UserDeleteActionImpl();

            action(impl);

            if (string.IsNullOrWhiteSpace(impl.Username))
            {
                throw new UserCredentialsMissingException("The username is missing.");
            }

            string url = $"api/users/{impl.Username}";

            HttpResponseMessage response = await HttpDelete(url, cancellationToken);

            Result result = response.GetResponse();

            LogInfo($"Sent request to RabbitMQ server to create user '{impl.Username}'");

            return(result);
        }