示例#1
0
        public static CartItemModel Create(
            DealModel deal,
            DealOptionModel dealOption,
            List<DealAttributeModel> selectedAttributeValues)
        {
            var cartItemModel = new CartItemModel
            {
                Deal = deal,
                DealOption = dealOption,
                Quantity = 1
            };

            foreach (var attr in selectedAttributeValues)
            {
                cartItemModel.attributeValues.Add(attr);
            }

            cartItemModel.Key = Guid.NewGuid().ToString();

            return cartItemModel;
        }
示例#2
0
        public static CartItemModel CreateCartItem(
            DealModel deal = null,
            DealOptionModel dealOption = null,
            List<DealAttributeModel> dealAttributes = null)
        {
            if (deal == null && dealOption == null)
            {
                deal = CreateCompleteDeal();
                dealOption = deal.Options.First();
            }

            if (dealAttributes == null)
            {
                dealAttributes = new List<DealAttributeModel>();
                foreach (var attr in dealOption.Attributes)
                {
                    dealAttributes.Add(attr);
                }
            }

            return CartItemModel.Create(deal, dealOption, dealAttributes);
        }
示例#3
0
 public void AddOption(DealOptionModel option)
 {
     options.Add(option);
 }