Пример #1
0
        public static OrderlineModel Create(
            CartItemModel cartItem)
        {
            var orderLine = new OrderlineModel
            {
                Deal = cartItem.Deal,
                DealOption = cartItem.DealOption
            };

            foreach (var attr in cartItem.AttributeValues)
            {
                orderLine.attributeValues.Add(attr);
            }

            orderLine.Key = Guid.NewGuid().ToString();
            orderLine.SpecialPrice = cartItem.DealOption.SpecialPrice * cartItem.Quantity;
            orderLine.RegularPrice = cartItem.DealOption.RegularPrice * cartItem.Quantity;
            orderLine.Quantity = cartItem.Quantity;

            return orderLine;
        }
Пример #2
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;
        }
Пример #3
0
 private static void AssertModelEqualityWithDeal(
     CartItemViewModel viewModel,
     CartItemModel domainModel,
     DealModel dealModel)
 {
     viewModel.DealId.ShouldBeEquivalentTo(dealModel.Key);
     viewModel.DealThumbnailUrl.ShouldBeEquivalentTo(dealModel.Images.OrderBy(a => a.Order).First().RelativeUrl);
     viewModel.DealUrl.ShouldBeEquivalentTo(dealModel.CanonicalUrl);
     viewModel.Id.ShouldBeEquivalentTo(domainModel.Key);
 }
Пример #4
0
 private static void AssertModelEquality(CartItemViewModel viewModel, CartItemModel domainModel)
 {
     viewModel.Id.ShouldBeEquivalentTo(domainModel.Key.ToString());
 }
Пример #5
0
 public void RemoveFromCart(CartItemModel cartItem)
 {
     this.cartItems.Remove(cartItem);
 }
Пример #6
0
 public void AddToCart(CartItemModel cartItem)
 {
     this.cartItems.Add(cartItem);
 }