public async ValueTask <AccountBalanceClass> GetBalanceClass(int accountNumber) { var bytes = await _byteArrayRepository.GetBalance(accountNumber); var json = Encoding.UTF8.GetString(bytes); return(JsonConvert.DeserializeObject <AccountBalanceClass>(json)); }
public static async Task WriteToResponseBody(HttpResponse response, IByteArrayRepository byteArrayRepository, int accountNumber) { response.Headers.Add("Content-Type", "application/json"); response.StatusCode = 200; var balanceTask = byteArrayRepository.GetBalance(accountNumber); var ordersTask = byteArrayRepository.GetOrders(accountNumber); await response.StartAsync(); var stream = response.Body; await stream.WriteAsync(ResponseExtensions.StartObject); await stream.WriteProperty(ResponseExtensions.AccountName, accountNumber); await stream.WriteAsync(ResponseExtensions.Comma); var balance = await balanceTask; await stream.WriteProperty(ResponseExtensions.BalanceName, balance); await stream.WriteAsync(ResponseExtensions.Comma); var orders = await ordersTask; await stream.WriteProperty(ResponseExtensions.OrdersName, orders); await stream.WriteAsync(ResponseExtensions.EndObject); }
public async ValueTask <AccountBalanceClass> GetBalanceClass(int accountNumber) { var bytes = await _byteArrayRepository.GetBalance(accountNumber); return(JsonSerializer.Deserialize <AccountBalanceClass>(bytes)); }