Example #1
0
        public async Task <IActionResult> AddAddressToWhitelist(
            WhitelistAddressRequest request)
        {
            var result = await _addressService.AddAddressToWhitelistAsync
                         (
                address : request.Address.ToLowerInvariant(),
                maxGasAmount : BigInteger.Parse(request.MaxGasAmount)
                         );

            switch (result)
            {
            case AddAddressResult.SuccessResult _:
                return(Ok());

            case AddAddressResult.HasAlreadyBeenAddedError _:
                return(Conflict());

            default:
                throw new NotSupportedException(
                          $"{nameof(_addressService.AddAddressToWhitelistAsync)} returned unsupported result.");
            }
        }