Beispiel #1
0
        public IEnumerable Handle(Func <Guid, TabAggregate> al, CloseTab c)
        {
            var tab = al(c.Id);

            if (!tab.Open)
            {
                throw new TabNotOpen();
            }
            if (tab.HasUnservedItems())
            {
                throw new TabHasUnservedItems();
            }
            if (c.AmountPaid < tab.ServedItemsValue)
            {
                throw new MustPayEnough();
            }

            yield return(new TabClosed
            {
                Id = c.Id,
                AmountPaid = c.AmountPaid,
                OrderValue = tab.ServedItemsValue,
                TipValue = c.AmountPaid - tab.ServedItemsValue
            });
        }
Beispiel #2
0
        public IEnumerable <IEvent> Handle(CloseTab c)
        {
            if (!open)
            {
                throw new TabNotOpen();
            }
            if (HasUnservedItems())
            {
                throw new TabHasUnservedItems();
            }
            if (c.AmountPaid < servedItemsValue)
            {
                throw new MustPayEnough();
            }

            yield return(new TabClosed
            {
                Id = c.Id,
                AmountPaid = c.AmountPaid,
                OrderValue = servedItemsValue,
                TipValue = c.AmountPaid - servedItemsValue
            });
        }