示例#1
0
 public async Task Handle(JobOrderExtendedEvent message)
 {
     using (var db = new AccountancyContext())
     {
         var jobOrder = db.JobOrders.OfType <JobOrder>().Where(jo => jo.OriginalId == message.JobOrderId).Single();
         jobOrder.DueDate = message.NewDueDate;
         jobOrder.Price   = message.Price;
         await db.SaveChangesAsync();
     }
 }
示例#2
0
        public void Extend(DateTime newDueDate, decimal price)
        {
            if (this.IsCompleted)
            {
                throw new InvalidOperationException("Can't extend a completed job order.");
            }
            if (this.DueDate > newDueDate)
            {
                throw new ArgumentException("A job order length cannot be reduced.", nameof(newDueDate));
            }

            var @event = new JobOrderExtendedEvent(
                this.Id,
                newDueDate,
                price
                );

            RaiseEvent(@event);
        }
示例#3
0
 public void ApplyEvent(JobOrderExtendedEvent evt)
 {
     this.DueDate = evt.NewDueDate;
     this.Price   = new PositiveMoney(evt.Price, this.Price.Currency);
 }
示例#4
0
文件: JobOrder.cs 项目: rioka/Merp
 public void ApplyEvent([AggregateId(nameof(JobOrderExtendedEvent.JobOrderId))] JobOrderExtendedEvent evt)
 {
     this.DueDate = evt.NewDueDate;
     this.Price   = new PositiveMoney(evt.Price, this.Price.Currency);
 }