示例#1
0
 private void UntagOrder(OrderTagValue orderTagValue)
 {
     OrderTagValues.Remove(orderTagValue);
 }
示例#2
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);
        }
示例#3
0
 public void UntagOrder(OrderTagValue orderTagValue)
 {
     OrderTagValues.Remove(orderTagValue);
     OrderTags       = JsonHelper.Serialize(OrderTagValues);
     _orderTagValues = null;
 }