public void Execute(ChangeMainOrderLineItemCommand command)
 {
     _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
     try
     {
         if (!DocumentExists(command.DocumentId))
         {
             _log.InfoFormat("Cannot Edit line item. Document does not exist  Execute {1} - Command Id {0} ", command.CommandId, command.GetType());
             return;
         }
         if (DocumentLineItemExists(command.LineItemId))
         {
             tblDocument doc = ExistingDocument(command.DocumentId);
             tblLineItems lineItem = doc.tblLineItems.First(s => s.id == command.LineItemId);
             lineItem.Quantity = command.NewQuantity;
             _cokeDataContext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
         _log.Error("AddOrderLineItemCommandHandler exception", ex);
         throw;
     }
 
 }
Ejemplo n.º 2
0
 public void Handle(ChangeMainOrderLineItemCommand command)
 {
     var order = GetOrder();
     var item = order.AllItems.Find(l => l.Id == command.LineItemId);
     if (item != null)
     {
         item.Quantity = command.NewQuantity;
     }
 }