public async ValueTask <AccountOrderCollectionClass> GetOrdersClass(int accountNumber) { var bytes = await _byteArrayRepository.GetOrders(accountNumber); var json = Encoding.UTF8.GetString(bytes); return(JsonConvert.DeserializeObject <AccountOrderCollectionClass>(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 <AccountOrderCollectionClass> GetOrdersClass(int accountNumber) { var bytes = await _byteArrayRepository.GetOrders(accountNumber); return(JsonSerializer.Deserialize <AccountOrderCollectionClass>(bytes)); }