예제 #1
0
        public bool ToggleOrderTag(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId)
        {
            var result = true;
            var otag   = OrderTagValues.FirstOrDefault(x => x.Name == orderTag.Name);

            if (otag == null)
            {
                if (orderTagGroup.MaxSelectedItems > 1 && OrderTagValues.Count(x => x.OrderTagGroupId == orderTagGroup.Id) >= orderTagGroup.MaxSelectedItems)
                {
                    return(false);
                }
                var tagIndex = -1;
                if (orderTagGroup.MaxSelectedItems == 1)
                {
                    var sTag = OrderTagValues.SingleOrDefault(x => x.OrderTagGroupId == orderTag.OrderTagGroupId);
                    if (sTag != null)
                    {
                        tagIndex = OrderTagValues.IndexOf(sTag);
                    }
                    OrderTagValues.Where(x => x.OrderTagGroupId == orderTagGroup.Id).ToList().ForEach(x => OrderTagValues.Remove(x));
                }
                TagOrder(orderTagGroup, orderTag, userId, tagIndex);
            }
            else
            {
                otag.Quantity++;
                if (orderTagGroup.MaxSelectedItems == 1 || (orderTag.MaxQuantity > 0 && otag.Quantity > orderTag.MaxQuantity))
                {
                    UntagOrder(otag);
                    result = false;
                }
            }
            return(result);
        }
예제 #2
0
        private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex, string tagNote)
        {
            var otag = new OrderTagValue
            {
                TagValue                = orderTag.Name,
                OrderTagGroupId         = orderTagGroup.Id,
                TagName                 = orderTagGroup.Name,
                TagNote                 = !string.IsNullOrEmpty(tagNote) ? tagNote : null,
                MenuItemId              = orderTag.MenuItemId,
                AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice,
                PortionName             = orderTag.MenuItemId > 0 ? PortionName : null,
                UserId   = userId,
                Quantity = 1,
                OrderKey = orderTagGroup.SortOrder.ToString("000") + orderTag.SortOrder.ToString("000")
            };

            otag.UpdatePrice(orderTag.Price);

            if (tagIndex > -1)
            {
                OrderTagValues.Insert(tagIndex, otag);
            }
            else
            {
                OrderTagValues.Add(otag);
            }
            OrderTags       = JsonHelper.Serialize(OrderTagValues);
            _orderTagValues = null;
        }
예제 #3
0
 public void TagIfNotTagged(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId)
 {
     if (OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name) == null)
     {
         ToggleOrderTag(orderTagGroup, orderTag, userId);
     }
 }
예제 #4
0
        private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex)
        {
            var otag = new OrderTagValue
            {
                Name                    = orderTag.Name,
                OrderTagGroupId         = orderTagGroup.Id,
                OrderTagGroupName       = orderTagGroup.Name,
                MenuItemId              = orderTag.MenuItemId,
                AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice,
                PortionName             = PortionName,
                SubValue                = !string.IsNullOrEmpty(orderTagGroup.ButtonHeader) && orderTag.Price == 0 && orderTagGroup.MaxSelectedItems == 1,
                UserId                  = userId,
                Quantity                = 1,
                NewTag                  = true,
                OrderKey                = orderTagGroup.Order.ToString("000") + orderTag.Order.ToString("000")
            };

            otag.UpdatePrice(TaxIncluded, TaxRate, orderTag.Price);

            if (tagIndex > -1)
            {
                OrderTagValues.Insert(tagIndex, otag);
            }
            else
            {
                OrderTagValues.Add(otag);
            }
        }
 public OrderTagButtonViewModel(IEnumerable<Order> selectedOrders, OrderTagGroup tagGroup, OrderTag model)
 {
     _selectedOrders = selectedOrders;
     Model = model;
     OrderTagGroup = tagGroup;
     if (string.IsNullOrEmpty(model.Name))
         model.Name = string.Format("[{0}]", Resources.NewProperty);
 }
예제 #6
0
        public void UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag)
        {
            var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name);

            if (value != null)
            {
                UntagOrder(value);
            }
        }
예제 #7
0
        public bool UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag)
        {
            var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.TagValue == orderTag.Name);

            if (value != null)
            {
                UntagOrder(value);
                return(true);
            }
            return(false);
        }
예제 #8
0
        private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex)
        {
            var otag = new OrderTagValue
                       {
                           Name = orderTag.Name,
                           OrderTagGroupId = orderTagGroup.Id,
                           OrderTagGroupName = orderTagGroup.Name,
                           MenuItemId = orderTag.MenuItemId,
                           AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice,
                           PortionName = PortionName,
                           SubValue = !string.IsNullOrEmpty(orderTagGroup.ButtonHeader) && orderTag.Price == 0 && orderTagGroup.MaxSelectedItems == 1,
                           UserId = userId,
                           Quantity = 1,
                           NewTag = true,
                           OrderKey = orderTagGroup.Order.ToString("000") + orderTag.Order.ToString("000")
                       };

            otag.UpdatePrice(TaxIncluded, TaxRate, orderTag.Price);

            if (tagIndex > -1)
                OrderTagValues.Insert(tagIndex, otag);
            else
                OrderTagValues.Add(otag);
        }
예제 #9
0
 public void UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag)
 {
     var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name);
     if (value != null) UntagOrder(value);
 }
예제 #10
0
 public bool ToggleOrderTag(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId)
 {
     var result = true;
     var otag = OrderTagValues.FirstOrDefault(x => x.Name == orderTag.Name);
     if (otag == null)
     {
         if (orderTagGroup.MaxSelectedItems > 1 && OrderTagValues.Count(x => x.OrderTagGroupId == orderTagGroup.Id) >= orderTagGroup.MaxSelectedItems) return false;
         var tagIndex = -1;
         if (orderTagGroup.MaxSelectedItems == 1)
         {
             var sTag = OrderTagValues.SingleOrDefault(x => x.OrderTagGroupId == orderTag.OrderTagGroupId);
             if (sTag != null) tagIndex = OrderTagValues.IndexOf(sTag);
             OrderTagValues.Where(x => x.OrderTagGroupId == orderTagGroup.Id).ToList().ForEach(x => OrderTagValues.Remove(x));
         }
         TagOrder(orderTagGroup, orderTag, userId, tagIndex);
     }
     else
     {
         otag.Quantity++;
         if (orderTagGroup.MaxSelectedItems == 1 || (orderTag.MaxQuantity > 0 && otag.Quantity > orderTag.MaxQuantity))
         {
             UntagOrder(otag);
             result = false;
         }
     }
     return result;
 }
예제 #11
0
 public void TagIfNotTagged(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId)
 {
     if (OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name) == null)
     {
         ToggleOrderTag(orderTagGroup, orderTag, userId);
     }
 }
 public GroupedOrderTagButtonViewModel(Order selectedItem, OrderTagGroup orderTagGroup)
 {
     _selectedItem = selectedItem;
     OrderTagGroup = orderTagGroup;
     UpdateNextTag(null);
 }
예제 #13
0
 public bool IsTaggedWith(OrderTagGroup orderTagGroup)
 {
     return Model.IsTaggedWith(orderTagGroup);
 }
예제 #14
0
        public void TagOrders(Ticket ticket, IEnumerable<Order> selectedOrders, OrderTagGroup orderTagGroup, OrderTag orderTag, string tagNote)
        {
            var so = selectedOrders.ToList();

            if (orderTagGroup.MaxSelectedItems == 1)
            {
                foreach (var order in so.Where(x => x.OrderTagExists(y => y.OrderTagGroupId == orderTagGroup.Id && y.TagValue != orderTag.Name)))
                {
                    var orderTagValue = order.GetOrderTagValues().First(x => x.OrderTagGroupId == orderTagGroup.Id);
                    order.UntagOrder(orderTagValue);
                    _applicationState.NotifyEvent(RuleEventNames.OrderUntagged,
                               new
                               {
                                   Ticket = ticket,
                                   Order = order,
                                   OrderTagName = orderTagGroup.Name,
                                   OrderTagValue = orderTagValue.TagValue
                               });

                }
            }

            foreach (var selectedOrder in so)
            {
                var result = selectedOrder.ToggleOrderTag(orderTagGroup, orderTag, _applicationState.CurrentLoggedInUser.Id, tagNote);

                if (orderTagGroup.SaveFreeTags && orderTagGroup.OrderTags.All(x => x.Name != orderTag.Name))
                {
                    _ticketDao.SaveFreeOrderTag(orderTagGroup.Id, orderTag);
                    _cacheService.ResetOrderTagCache();
                }
                _applicationState.NotifyEvent(result ? RuleEventNames.OrderTagged : RuleEventNames.OrderUntagged,
                new
                {
                    Ticket = ticket,
                    Order = selectedOrder,
                    OrderTagName = orderTagGroup.Name,
                    OrderTagValue = orderTag.Name
                });
            }
        }
예제 #15
0
 public void UntagOrders(Ticket ticket, IEnumerable<Order> selectedOrders, OrderTagGroup orderTagGroup, OrderTag orderTag)
 {
     foreach (var selectedOrder in selectedOrders.Where(selectedOrder => selectedOrder.UntagIfTagged(orderTagGroup, orderTag)))
     {
         _applicationState.NotifyEvent(RuleEventNames.OrderUntagged,
                                        new
                                            {
                                                Ticket = ticket,
                                                Order = selectedOrder,
                                                OrderTagName = orderTagGroup.Name,
                                                OrderTagValue = orderTag.Name
                                            });
     }
 }
예제 #16
0
 public OrderTagGroupViewModel(OrderTagGroup model, IEnumerable<Order> selectedOrders)
 {
     Model = model;
     _selectedOrders = selectedOrders;
 }
예제 #17
0
 private static IEnumerable<OrderTagButtonViewModel> GetOrderTags(IEnumerable<Order> selectedOrders, OrderTagGroup baseModel)
 {
     return baseModel.OrderTags.Select(item => new OrderTagButtonViewModel(selectedOrders, baseModel, item));
 }
예제 #18
0
 public void UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId)
 {
     var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name);
     if (value != null) ToggleOrderTag(orderTagGroup, orderTag, userId);
 }
예제 #19
0
 private bool CanShowOrderTagsExecute(OrderTagGroup arg)
 {
     return SelectedOrders.Any();
 }
예제 #20
0
        public void ToggleOrderTag(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId)
        {
            var result = _model.ToggleOrderTag(orderTagGroup, orderTag, userId);
            _automationService.NotifyEvent(result ? RuleEventNames.OrderTagged : RuleEventNames.OrderUntagged,
            new
            {
                Order = Model,
                OrderTagName = orderTagGroup.Name,
                OrderTagValue = orderTag.Name
            });

            RefreshProperties();
            RaisePropertyChanged(() => TotalPrice);
            RaisePropertyChanged(() => Quantity);
            RaisePropertyChanged(() => Description);
            RaisePropertyChanged(() => FontWeight);
            RaisePropertyChanged(() => IsLocked);
        }
예제 #21
0
 private void OnShowOrderTagsExecute(OrderTagGroup orderTagGroup)
 {
     var orderTagData = new OrderTagData
     {
         SelectedOrders = SelectedOrders,
         OrderTagGroup = orderTagGroup,
         Ticket = SelectedTicket
     };
     orderTagData.PublishEvent(EventTopicNames.SelectOrderTag);
 }
예제 #22
0
 public static OrderTag AddDefaultMenuItemProperty(OrderTagGroup item)
 {
     return item.AddOrderTag("", 0);
 }
예제 #23
0
 private bool CanShowOrderTagsExecute(OrderTagGroup arg)
 {
     if (SelectedOrders.Count() == 0) return false;
     if (!arg.DecreaseOrderInventory && SelectedOrders.Any(x => !x.Locked && !x.IsTaggedWith(arg))) return false;
     if (SelectedOrders.Any(x => !x.DecreaseInventory && !x.IsTaggedWith(arg))) return false;
     return !arg.UnlocksOrder || !SelectedOrders.Any(x => x.Locked && x.OrderTagValues.Count(y => y.OrderTagGroupId == arg.Id) > 0);
 }
예제 #24
0
 public OrderTagGroupButton(OrderTagGroup orderTagGroup)
 {
     Model = orderTagGroup;
     Name = Model.Name;
 }
예제 #25
0
 public bool UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag)
 {
     var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.TagValue == orderTag.Name);
     if (value != null)
     {
         UntagOrder(value);
         return true;
     }
     return false;
 }
예제 #26
0
        private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex)
        {
            var otag = new OrderTagValue
                       {
                           Name = orderTag.Name,
                           OrderTagGroupId = orderTagGroup.Id,
                           MenuItemId = orderTag.MenuItemId,
                           AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice,
                           PortionName = PortionName,
                           UserId = userId,
                           DecreaseInventory = orderTagGroup.DecreaseOrderInventory,
                           CalculatePrice = orderTagGroup.CalculateOrderPrice,
                           Quantity = 1,
                           UnlocksOrder = orderTagGroup.UnlocksOrder,
                           NewTag = true
                       };

            otag.UpdatePrice(TaxIncluded, TaxRate, orderTag.Price);

            if (tagIndex > -1)
                OrderTagValues.Insert(tagIndex, otag);
            else
                OrderTagValues.Add(otag);

            CalculatePrice = orderTagGroup.CalculateOrderPrice;
            DecreaseInventory = orderTagGroup.DecreaseOrderInventory;
            if (orderTagGroup.UnlocksOrder) Locked = false;
        }
예제 #27
0
 public bool IsTaggedWith(OrderTagGroup orderTagGroup)
 {
     return(OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id) != null);
 }
예제 #28
0
        private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex, string tagNote)
        {
            var otag = new OrderTagValue
                       {
                           TagValue = orderTag.Name,
                           OrderTagGroupId = orderTagGroup.Id,
                           TagName = orderTagGroup.Name,
                           TagNote = !string.IsNullOrEmpty(tagNote) ? tagNote : null,
                           MenuItemId = orderTag.MenuItemId,
                           AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice,
                           PortionName = orderTag.MenuItemId > 0 ? PortionName : null,
                           UserId = userId,
                           Quantity = 1,
                           OrderKey = orderTagGroup.SortOrder.ToString("000") + orderTag.SortOrder.ToString("000")
                       };

            otag.UpdatePrice(orderTag.Price);

            if (tagIndex > -1)
                OrderTagValues.Insert(tagIndex, otag);
            else
                OrderTagValues.Add(otag);
            OrderTags = JsonHelper.Serialize(OrderTagValues);
            _orderTagValues = null;
        }
예제 #29
0
 public bool IsTaggedWith(OrderTagGroup orderTagGroup)
 {
     return OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id) != null;
 }
예제 #30
0
 public OrderTagButton(OrderTagGroup orderTagGroup)
 {
     Model = orderTagGroup;
     Name = Model.ButtonHeader;
 }