Exemplo n.º 1
0
 private void HandleEvent(BookIssueStockEvent domainEvent)
 {
     using (QueryDBEntities _dbContext = new QueryDBEntities())
     {
         Book book = _dbContext.Book.FirstOrDefault(t => t.AggregateRootId == domainEvent.AggregateRootId);
         book.Inventory = book.Inventory - domainEvent.Quantity;
         _dbContext.Entry(book).State = EntityState.Modified;
         _dbContext.SaveChanges();
     }
 }
        public bool Handle(BookIssueStockEvent message)
        {
            string updateBookStockSql = @"UPDATE [Books] SET [Inventory]=[Inventory]-@quantity WHERE [AggregateRootId]=@aggregateRootId";
            var    rowsAffected       = SqlHelper.ExecuteNonQuery(this.QueryDBConnectionString,
                                                                  CommandType.Text,
                                                                  updateBookStockSql,
                                                                  new SqlParameter("@quantity", message.Quantity),
                                                                  new SqlParameter("@aggregateRootId", message.AggregateRootId));

            return(rowsAffected > 0);
        }
Exemplo n.º 3
0
 public void HandleEvent(BookIssueStockEvent e)
 {
     this.Inventory -= e.Quantity;
 }
Exemplo n.º 4
0
 private void HandleBookIssueStockEvent(BookIssueStockEvent e)
 {
     this.Inventory -= e.Quantity;
 }