public object Post(OrderInQueue request)
 {
     request.CreatedDate = DateTime.Now;
     RedisExec(
         (redisCon) => redisCon.SetEntryInHash("urn:OrdersInQueue", request.OrderId.ToString(), request.ToJson()));
     
     return "Item Succesfully Added";
 }
        public List<OrderInQueue> Get (OrderInQueue request)
        {
            var ordersInQueue = RedisExec((redisCon) => redisCon.GetAllEntriesFromHash("urn:OrdersInQueue")
                                            .Select(x => x.Value.FromJson<OrderInQueue>())
                                            .OrderBy(x => x.CreatedDate).ToList());

            return ordersInQueue;
        }
        public void StartSubscriberThreads() //need to resolve dependencies...
        {
            //Create a fulfillment when an Order is posted
            StartThread("NewOrder", (channel, msg) =>
                    {
                        Fulfillment newFulfillment;
                        
                        var createOrderRequest = msg.FromJson<Order>();
                        var createFulfillment = new CreateFulfillment
                        {
                            OrderId = createOrderRequest.Id,
                            ItemId = createOrderRequest.ItemId,
                            ItemName = createOrderRequest.ItemName,
                            Quantity = createOrderRequest.Quantity
                        };
                        using (var service = Container.Resolve<FulfillmentService>())
                        {
                            newFulfillment = service.Post(createFulfillment);
                        }

                        //Alert connections
                        var hub = GlobalHost.ConnectionManager.GetHubContext("FulfillmentGridHub");
                        if (hub != null)
                        {
                            hub.Clients.All.addToGrid(newFulfillment);
                        }
                    });

            //Create an Order in the Queue when an Order is posted
            StartThread("NewOrder", (channel, msg) =>
                    {
                        var createOrderRequest = msg.FromJson<Order>();
                        var createOrderInQueue = new OrderInQueue
                        {
                            OrderId = createOrderRequest.Id,
                            CustomerName = createOrderRequest.CustomerFirstName,
                            ItemId = createOrderRequest.ItemId,
                            ItemName = createOrderRequest.ItemName,
                            Quantity = createOrderRequest.Quantity,
                            Status = "New"
                        };
                        using (var service = Container.Resolve<OrderQueueService>())
                        {
                            service.Post(createOrderInQueue);
                        }

                        //Alert connections
                        var hub = GlobalHost.ConnectionManager.GetHubContext("OrdersQueueGridHub");
                        if (hub != null)
                        {
                            hub.Clients.All.addToGrid(createOrderInQueue);
                        }
                    });
        }