Ejemplo n.º 1
0
        protected override async Task ExecuteAsync(IConsole console)
        {
            var creationTask  = ServerAccessor.CreatePlotterAsync(Name, Username, Password);
            var plotterResult = await creationTask.Try();

            if (plotterResult == null)
            {
                var response = (creationTask.Exception.InnerException as HttpRequestException)?.StatusCode;
                if (response == null || !response.HasValue)
                {
                    throw creationTask.Exception.InnerException;
                }
                var responseCode = response.Value;

                if (responseCode == HttpStatusCode.NotFound)
                {
                    await ErrorLineAsync("This pool does not support plotter creation!");
                }
                else
                {
                    throw creationTask.Exception.InnerException;
                }

                return;
            }

            await SuccessLineAsync("Successfully created plotter!");
            await TableAsync(new Dictionary <string, Func <CreatePlotterResult, object> >()
            {
                ["Id"]    = x => x.Info.Id,
                ["Name"]  = x => x.Info.Name,
                ["Token"] = x => x.Token,
            }, new[] { plotterResult });
        }