Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 13
0
 public bool IsTaggedWith(OrderTagGroup orderTagGroup)
 {
     return Model.IsTaggedWith(orderTagGroup);
 }
Ejemplo n.º 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
                });
            }
        }
Ejemplo n.º 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
                                            });
     }
 }
Ejemplo n.º 16
0
 public OrderTagGroupViewModel(OrderTagGroup model, IEnumerable<Order> selectedOrders)
 {
     Model = model;
     _selectedOrders = selectedOrders;
 }
Ejemplo n.º 17
0
 private static IEnumerable<OrderTagButtonViewModel> GetOrderTags(IEnumerable<Order> selectedOrders, OrderTagGroup baseModel)
 {
     return baseModel.OrderTags.Select(item => new OrderTagButtonViewModel(selectedOrders, baseModel, item));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 19
0
 private bool CanShowOrderTagsExecute(OrderTagGroup arg)
 {
     return SelectedOrders.Any();
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 21
0
 private void OnShowOrderTagsExecute(OrderTagGroup orderTagGroup)
 {
     var orderTagData = new OrderTagData
     {
         SelectedOrders = SelectedOrders,
         OrderTagGroup = orderTagGroup,
         Ticket = SelectedTicket
     };
     orderTagData.PublishEvent(EventTopicNames.SelectOrderTag);
 }
Ejemplo n.º 22
0
 public static OrderTag AddDefaultMenuItemProperty(OrderTagGroup item)
 {
     return item.AddOrderTag("", 0);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 24
0
 public OrderTagGroupButton(OrderTagGroup orderTagGroup)
 {
     Model = orderTagGroup;
     Name = Model.Name;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 27
0
 public bool IsTaggedWith(OrderTagGroup orderTagGroup)
 {
     return(OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id) != null);
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 29
0
 public bool IsTaggedWith(OrderTagGroup orderTagGroup)
 {
     return OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id) != null;
 }
Ejemplo n.º 30
0
 public OrderTagButton(OrderTagGroup orderTagGroup)
 {
     Model = orderTagGroup;
     Name = Model.ButtonHeader;
 }