Ejemplo n.º 1
0
        public IHttpActionResult RemoveItem([FromBody] RemoveItemModel model)
        {
            var basketId  = model.BasketId;
            var productId = model.ProductId;
            var cmd       = Command.NewRemoveItem(ProductId.NewProductId(productId), model.Quantity);
            var envelope  = createCommand(AggregateId.NewAggregateId(basketId), AggregateVersion.Irrelevant, null, null, null, cmd);

            var basket = CommitCommand(envelope);

            return(Ok(basket));
        }
Ejemplo n.º 2
0
        public IHttpActionResult AddItem([FromBody] AddItemModel model)
        {
            var basketId = model.BasketId;

            if (model.BasketId == Guid.Empty)
            {
                basketId = Guid.NewGuid();
                var cmd      = Command.Create;
                var envelope = createCommand(AggregateId.NewAggregateId(basketId), AggregateVersion.NewExpected(0), null, null, null, cmd);

                CommitCommand(envelope);
            }

            // TODO: get model price and name from api by id
            var productId   = model.ProductId;
            var item        = new BasketItem(ProductId.NewProductId(productId), model.Name, model.Price, model.Quantity);
            var addCmd      = Command.NewAddItem(item);
            var addEnvelope = createCommand(AggregateId.NewAggregateId(basketId), AggregateVersion.Irrelevant, null, null, null, addCmd);

            var basket = CommitCommand(addEnvelope);

            return(Ok(basket));
        }
Ejemplo n.º 3
0
 public Product Milk()
 {
     return(new Product(ProductId.NewProductId(), "milk", 80.00));
 }
Ejemplo n.º 4
0
 public Product MeatBalls()
 {
     return(new Product(ProductId.NewProductId(), "Meat Balls", 325.00));
 }