Beispiel #1
0
        public void CartCreated(Guid clientId, Guid cartId)
        {
            // Overwrite old cart, when new cart happens
            if (!clientCartMapping.ContainsKey(clientId))
            {
                clientCartMapping.Add(clientId, cartId);
            }
            else
            {
                var oldCartId = clientCartMapping[clientId];
                cartItemsMapping.Remove(oldCartId);
                clientCartMapping[clientId] = cartId;
            }

            if (!cartItemsMapping.ContainsKey(clientId))
            {
                cartItemsMapping.Add(cartId, new BasketReadModel {
                    ClientId = clientId, CartId = cartId
                });
            }
            else
            {
                cartItemsMapping[cartId] = new BasketReadModel {
                    ClientId = clientId, CartId = cartId
                };
            }
        }
Beispiel #2
0
 private void Update(BasketReadModel model)
 {
     model.TotalPrice = model.Items.Sum(item => item.TotalPrice);
     model.ItemCount  = model.Items.Select(item => item.Quantity).Sum();
 }