Exemplo n.º 1
0
        public bool CanDeselectOrder(Order order)
        {
            if (!order.DecreaseInventory || order.Locked)
            {
                return(true);
            }
            var ots = _applicationState.GetOrderTagGroups(order.MenuItemId);

            return(ots.Where(x => x.MinSelectedItems > 0).All(orderTagGroup => order.GetOrderTagValues(x => x.OrderTagGroupId == orderTagGroup.Id).Count() >= orderTagGroup.MinSelectedItems));
        }
        public bool ShouldDisplay(Ticket value, IEnumerable <Order> selectedOrders)
        {
            ResetValues(value);
            if (selectedOrders == null)
            {
                return(false);
            }
            var so = selectedOrders.ToList();

            SelectedOrder = so.Count() == 1 ? so.ElementAt(0) : null;
            if (so.Any(x => x.Locked || !x.DecreaseInventory))
            {
                return(false);
            }

            if (SelectedTicket != null && SelectedOrder != null)
            {
                var portions = _cacheService.GetMenuItemPortions(SelectedOrder.MenuItemId);

                if (SelectedOrder.PortionCount > 1)
                {
                    SelectedItemPortions.AddRange(portions);
                }

                RaisePropertyChanged(nameof(IsPortionsVisible));

                var orderTagGroups = _applicationState.GetOrderTagGroups(SelectedOrder.MenuItemId).Where(x => !x.Hidden).ToList();

                OrderTagGroups.AddRange(
                    orderTagGroups
                    .Where(x => string.IsNullOrEmpty(x.GroupTag))
                    .Select(x => new OrderTagGroupViewModel(x, so)));

                if (SelectedOrder != null)
                {
                    GroupedOrderTagGroups.AddRange(
                        orderTagGroups
                        .Where(x => !string.IsNullOrEmpty(x.GroupTag) && x.OrderTags.Count > 1)
                        .GroupBy(x => x.GroupTag)
                        .Select(x => new GroupedOrderTagViewModel(SelectedOrder, x)));
                }
            }

            return(SelectedItemPortions.Count > 1 || OrderTagGroups.Count > 0 || GroupedOrderTagGroups.Count > 0);
        }
Exemplo n.º 3
0
        public OrderTagGroup GetMandantoryOrderTagGroup(Order order)
        {
            Func <OrderTagValue, decimal> quantity = null;

            if (order.Locked)
            {
                return(null);
            }
            IApplicationState applicationState = this._applicationState;
            string            portionName      = order.PortionName;

            int[] menuItemId = new int[] { order.MenuItemId };
            return((
                       from x in applicationState.GetOrderTagGroups(portionName, menuItemId)
                       where x.MinSelectedItems > 0
                       select x).FirstOrDefault <OrderTagGroup>((OrderTagGroup orderTagGroup) => {
                IEnumerable <OrderTagValue> orderTagValues = order.GetOrderTagValues((OrderTagValue x) => x.OrderTagGroupId == orderTagGroup.Id);
                if (quantity == null)
                {
                    quantity = (OrderTagValue x) => x.Quantity;
                }
                return orderTagValues.Sum <OrderTagValue>(quantity) < orderTagGroup.MinSelectedItems;
            }));
        }
Exemplo n.º 4
0
        public bool CanDeselectOrder(Order order)
        {
            Func <OrderTagValue, decimal> quantity = null;

            if (!order.DecreaseInventory || order.Locked)
            {
                return(true);
            }
            IApplicationState applicationState = this._applicationState;
            string            portionName      = order.PortionName;

            int[] menuItemId = new int[] { order.MenuItemId };
            return((
                       from x in applicationState.GetOrderTagGroups(portionName, menuItemId)
                       where x.MinSelectedItems > 0
                       select x).All <OrderTagGroup>((OrderTagGroup orderTagGroup) => {
                IEnumerable <OrderTagValue> orderTagValues = order.GetOrderTagValues((OrderTagValue x) => x.OrderTagGroupId == orderTagGroup.Id);
                if (quantity == null)
                {
                    quantity = (OrderTagValue x) => x.Quantity;
                }
                return orderTagValues.Sum <OrderTagValue>(quantity) >= orderTagGroup.MinSelectedItems;
            }));
        }