Пример #1
0
        public void TakeOrder(int ticketCount, decimal ticketPrice, string creditCardNumber)
        {
            var order = new Order
            {
                CreditCardNumber = creditCardNumber,
                TicketCount      = ticketCount,
                Subtotal         = ticketCount * ticketPrice
            };

            PendingOrders.Add(order);

            Publisher.Publish(new OrderPlaced {
                Order = order
            });
        }
Пример #2
0
        private void ReQueryOrders(object sender, EventArgs e)
        {
            var oldMergeOption = DataService.MergeOption;

            DataService.MergeOption = MergeOption.OverwriteChanges;
            var orders = DataService.Orders.Expand("OrderItems").Where(x => x.OrderStateId == OrderStates.Cooking).ToList();

            foreach (var order in orders.Where(order => !PendingOrders.Contains(order)))
            {
                PendingOrders.Add(order);
            }
            foreach (var pendingOrder in PendingOrders.Where(pendingOrder => !orders.Contains(pendingOrder)))
            {
                PendingOrders.Remove(pendingOrder);
            }
            DataService.MergeOption = oldMergeOption;
        }
Пример #3
0
 /// <summary>
 /// Queue order ticket for execution. Typically, algorithms won't
 /// use this function directly, but use Instrument.Trade instead.
 /// </summary>
 /// <param name="order"></param>
 public void QueueOrder(Order order)
 {
     order.QueueTime = SimTime.BarsAvailable > 0
         ? SimTime[0] : default(DateTime);
     PendingOrders.Add(order);
 }
        public void SetDay(DateTime dateTime)
        {
            CanGoBack = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day) > DateTime.Today;

            Device.BeginInvokeOnMainThread(async() =>
            {
                IsBusy = true;

                if (string.IsNullOrEmpty(Shared.RestaurantLocation))
                {
                    var restaurants = await Shared.APIs.IRestaurantBusiness.GetLocationIds_Async();
                    if (restaurants.Count > 0)
                    {
                        Shared.RestaurantLocation = restaurants.First().ToString();
                    }
                }

                PendingOrders.Clear();
                var start = dateTime.AddHours(-dateTime.Hour).AddMinutes(-dateTime.Minute).AddSeconds(-dateTime.Second);
                var end   = start.AddHours(23).AddMinutes(59).AddSeconds(59);

                _displayedDay = new DateTime(dateTime.Ticks);

                if (start.Year == DateTime.Today.Year && start.Month == DateTime.Today.Month && start.Day == DateTime.Today.Day)
                {
                    DisplayedDayFormatted = "Today";
                }
                else
                {
                    DisplayedDayFormatted = _displayedDay.ToString("MMMM dd, yyyy");
                }

                TimeStamp startStamp = start;
                TimeStamp endStamp   = end;

                IsShowingEmptyResults = false;
                IsShowingResults      = false;

                var deliveryResponse = await Shared.APIs.IRestaurantBusiness.GetOrders_Async(Shared.RestaurantLocation, true, false, true, true, startStamp, endStamp);
                var pickupResponse   = await Shared.APIs.IRestaurantBusiness.GetOrders_Async(Shared.RestaurantLocation, false, true, true, true, startStamp, endStamp);

                PendingOrders.Clear();

                if (deliveryResponse.Count > 0 || deliveryResponse.Count > 0)
                {
                    deliveryResponse.AddRange(pickupResponse);
                    var groups = deliveryResponse.GroupBy(x => x.WrappedScheduledService.ServiceStartTime.Time);
                    foreach (var group in groups)
                    {
                        var time = group.First().WrappedScheduledService.ServiceStartTime.Time;

                        var delivery = group.Count(x => (x.WrappedScheduledService as ScheduledRestaurantService).Delivery == true);
                        var pickups  = group.Count(x => (x.WrappedScheduledService as ScheduledRestaurantService).Delivery == false);

                        PendingOrders.Add(new OrderAdapterModel(DateTime.Parse(time).ToString("hh:mm tt"), delivery, pickups));
                    }

                    IsShowingEmptyResults = false;
                    IsShowingResults      = true;
                }
                else
                {
                    IsShowingEmptyResults = true;
                    IsShowingResults      = false;
                }

                IsBusy = false;
            });
        }