Ejemplo n.º 1
0
        public Document2 Create(int pagesCount)
        {
            Document2 result = new Document2(pagesCount);

            _dependencyInjector.InjectDependencies(result);
            return(result);
        }
Ejemplo n.º 2
0
        public Shipment CreateShipment(AggregateId orderId)
        {
            Shipment shipment = new Shipment(orderId);

            _dependencyInjector.InjectDependencies(shipment);

            return(shipment);
        }
Ejemplo n.º 3
0
        public Invoice Create(AggregateId orderId, ClientData clientData)
        {
            AggregateId number = _numberGenerator.GenerateNextInvoiceNumber();

            _eventPublisher.Publish(new OrderInvoicedEvent(orderId, number));

            Invoice invoice = new Invoice(number, clientData);

            _dependencyInjector.InjectDependencies(invoice);

            return(invoice);
        }
Ejemplo n.º 4
0
        public TAggregateRoot Get(int id)
        {
            TAggregateRoot result = _session.Get <TAggregateRoot>(id);

            if (result == null)
            {
                return(null);
            }
            if ((result as ISoftDeletable).IsRemoved())
            {
                return(null);
            }
            _dependencyInjector.InjectDependencies(result);

            return(result);
        }
Ejemplo n.º 5
0
        public TAggregateRoot Load(AggregateId id)
        {
            var result = _session.Get <TAggregateRoot>(id);

            if (result == null)
            {
                return(null);
            }
            if (result.IsRemoved())
            {
                return(null);
            }
            _dependencyInjector.InjectDependencies(result);

            return(result);
        }
Ejemplo n.º 6
0
        public Purchase Create(AggregateId orderId, Client.Client client, Offer.Offer offer)
        {
            if (!CanPurchse(client, offer.AvailableItems))
            {
                throw new DomainOperationException(client.AggregateId, "client can not purchase");
            }

            List <PurchaseItem> items = new List <PurchaseItem>(offer.AvailableItems.Count());
            Money purchaseTotlCost    = Money.ZERO;

            foreach (OfferItem item in offer.AvailableItems)
            {
                PurchaseItem purchaseItem = new PurchaseItem(item.ProductData, item.TotalCost);
                items.Add(purchaseItem);
                purchaseTotlCost = purchaseTotlCost.Add(purchaseItem.TotalCost);
            }

            Purchase purchase = new Purchase(orderId, client.AggregateId,
                                             items, Date.Today(), false, purchaseTotlCost);

            _dependencyInjector.InjectDependencies(purchase);

            return(purchase);
        }