コード例 #1
0
        public async Task <JsonResult> Transaction([FromBody] TransactionRequest request)
        {
            return(await ProcessRequest(async() =>
            {
                if (string.IsNullOrEmpty(request.Sender) || string.IsNullOrEmpty(request.Recipient))
                {
                    return GenerateBadRequestResponse(new ArgumentException("Sender and Recipient are required"));
                }

                if (request.Amount == 0)
                {
                    return GenerateBadRequestResponse(new ArgumentException("Amount must not be zero"));
                }

                var response = _localBlockChain.CreateTransaction(request.Sender, request.Recipient, request.Amount);

                return GenerateOkResponse(response);
            }));
        }