예제 #1
0
        private static async Task HandleModifyBlock()
        {
            Console.WriteLine("-------------");
            Console.WriteLine("Provide block order id for modification:");

            var orderId = RequestOrderId();

            try
            {
                var existingBlockOrder = await _auctionApiClient.GetBlockOrderAsync(orderId);

                Console.WriteLine("Existing block order:");
                ConsoleHelper.WriteBlockList(existingBlockOrder);
                if (!existingBlockOrder.Blocks.Any() ||
                    existingBlockOrder.Blocks.All(x => x.State == OrderStateType.Cancelled))
                {
                    Console.WriteLine("Existing block order cancelled, modifying by adding blocks...");
                    existingBlockOrder.Blocks = OrderGenerator.GenerateBlocks(ResolveBlockOrderType(existingBlockOrder), _selectedAuction)
                                                .ToList();
                }
                else
                {
                    Console.WriteLine("Modifying volume for first block and first period..");
                    existingBlockOrder.Blocks.First().Periods.First().Volume += 50;
                }


                await _auctionApiClient.ModifyBlockOrder(orderId, existingBlockOrder.Blocks);

                var modifiedOrder = await _auctionApiClient.GetBlockOrderAsync(orderId);

                Console.WriteLine("Modified block order:");
                ConsoleHelper.WriteBlockList(modifiedOrder);
            }
            catch (AuctionApiException exception)
            {
                WriteException(exception);
            }
            catch (ApiException exception)
            {
                WriteException(exception);
            }
        }