public async Task <ActionResult <OrderWithStatus> > GetOrderWithStatus(Guid orderId) { Order order = await _db.GetOrder(orderId); if (order == null) { return(NotFound()); } return(OrderWithStatus.FromOrder(order)); }
public override async Task GetStatus(StatusRequest request, IServerStreamWriter <StatusUpdate> responseStream, ServerCallContext context) { var order = await _db.GetOrder(new Guid(request.Id)); while (!context.CancellationToken.IsCancellationRequested) { var orderStatus = OrderWithStatus.FromOrder(order); await responseStream.WriteAsync(new StatusUpdate() { StatusText = orderStatus.StatusText, Progress = orderStatus.Progress }); if (orderStatus.StatusText == "Completed") { break; } await Task.Delay(5000); } }
public async Task <ActionResult <List <OrderWithStatus> > > GetOrders(string userId) { var orders = await _db.GetOrdersForUser(userId); return(orders.Select(o => OrderWithStatus.FromOrder(o)).ToList()); }