예제 #1
0
        public void RemovePromotionId(long promotionId)
        {
            if (PromotionIds != null)
            {
                var list = PromotionIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

                var hash = new Dictionary <long, int>();

                foreach (var item in list)
                {
                    var parts = item.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);

                    hash.Add(long.Parse(parts[0]), int.Parse(parts[1]));
                }

                if (hash.ContainsKey(promotionId))
                {
                    hash.Remove(promotionId);
                    PromotionIds = string.Join(",",
                                               hash.Select(h => h.Key.ToString() + "=" + h.Value.ToString()).ToList());
                }

                FreeQuantity = hash.Sum(h => h.Value);
            }
        }
예제 #2
0
        public Dictionary <long, int> GetFreePromotions()
        {
            if (PromotionIds == null)
            {
                return(new Dictionary <long, int>());
            }

            var list = PromotionIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            var hash = new Dictionary <long, int>();

            foreach (var item in list)
            {
                var parts = item.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);

                hash.Add(long.Parse(parts[0]), int.Parse(parts[1]));
            }

            return(hash);
        }
예제 #3
0
        public int GetFreeCountByPromotionId(long promotionId)
        {
            if (PromotionIds == null)
            {
                return(-1);
            }

            var list = PromotionIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            var hash = new Dictionary <long, int>();

            foreach (var item in list)
            {
                var parts = item.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);

                hash.Add(long.Parse(parts[0]), int.Parse(parts[1]));
            }

            if (hash.ContainsKey(promotionId))
            {
                return(hash[promotionId]);
            }
            return(-1);
        }