Esempio n. 1
0
        public bool ToggleOrderTag(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, string tagNote)
        {
            var result = true;
            var otag   = OrderTagValues.FirstOrDefault(x => x.TagValue == 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, tagNote);
            }
            else
            {
                otag.Quantity++;
                if (orderTagGroup.MaxSelectedItems == 1 || (orderTag.MaxQuantity > 0 && otag.Quantity > orderTag.MaxQuantity))
                {
                    UntagOrder(otag);
                    result = false;
                }
            }
            OrderTags = JsonHelper.Serialize(OrderTagValues);
            return(result);
        }
Esempio 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"),
                TaxFree  = orderTagGroup.TaxFree
            };

            otag.UpdatePrice(orderTag.Price);

            if (tagIndex > -1)
            {
                OrderTagValues.Insert(tagIndex, otag);
            }
            else
            {
                OrderTagValues.Add(otag);
            }
            OrderTags       = JsonHelper.Serialize(OrderTagValues);
            _orderTagValues = null;
        }
Esempio n. 3
0
 public void TagIfNotTagged(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, string tagNote)
 {
     if (OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.TagValue == orderTag.Name) == null)
     {
         ToggleOrderTag(orderTagGroup, orderTag, userId, tagNote);
     }
 }
Esempio n. 4
0
        public OrderTag AddOrderTag(string name, decimal price)
        {
            var prp = new OrderTag {
                Name = name, Price = price
            };

            OrderTags.Add(prp);
            return(prp);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
 public bool IsTaggedWith(OrderTag orderTag)
 {
     return(OrderTagValues.Any(x => x.TagValue == orderTag.Name));
 }