Exemplo n.º 1
0
        public async Task RevertStatus(int id)
        {
            var data    = new DataBaseAccess(PizzaDbFactory.GetPizzaContext());
            var updated = await data.RevertStatus(id);

            await Clients.Caller.SendAsync("UpdateOrder", updated);
        }
Exemplo n.º 2
0
        //Client web app calls this to get information about their order as it progresses.
        public async Task GetOrderUpdates(int id)
        {
            var data = new DataBaseAccess(PizzaDbFactory.GetPizzaContext());

            OrderStatus currentStatus = await data.GetOrderStatus(id);

            await Clients.Caller.SendAsync("UpdateStatus", currentStatus);

            do
            {
                data = new DataBaseAccess(PizzaDbFactory.GetPizzaContext());
                var newStatus = await data.GetOrderStatus(id);

                if (newStatus != currentStatus)
                {
                    currentStatus = newStatus;
                    await Clients.Caller.SendAsync("UpdateStatus", currentStatus);
                }
                Thread.Sleep(2000);
            } while (currentStatus != OrderStatus.Completed);
            await Clients.Caller.SendAsync("Finished");
        }