Example #1
0
        public static Customer Create(string name)
        {
            var fact = new CustomerCreatedFact
                       {
                           AggregateRootId = Guid.NewGuid(),
                           Name = name,
                       };

            var customer = new Customer();
            customer.Append(fact);
            customer.Apply(fact);
            return customer;
        }
Example #2
0
        internal bool TryReserveTicketsFor(Customer customer, int numTickets)
        {
            var requiredCapacity = _ticketsSold + numTickets;
            if (Capacity < requiredCapacity) return false;

            var fact = new TicketReservedFact
                       {
                           AggregateRootId = Id,
                           CustomerId = customer.Id,
                           NumTickets = numTickets,
                       };

            Append(fact);
            Apply(fact);
            return true;
        }