public void Execute(ApproveOrderLineItemCommand command)
        {
            _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
            try
            {
                if (!DocumentExists(command.DocumentId))
                {
                    _log.InfoFormat("Cannot approve line item. Document does not exist  Execute {1} - Command Id {0} ", command.CommandId, command.GetType());
                    return;
                }
                if (!DocumentLineItemExists(command.LineItemId))
                {
                    _log.InfoFormat("Cannot Update line item {0}. Line item already does not exists", command.CommandId);
                    return;
                }

                tblDocument doc = ExistingDocument(command.DocumentId);
                tblLineItems lineItem = doc.tblLineItems.FirstOrDefault(s => s.id == command.LineItemId);
               
                lineItem.LostSaleQuantity = command.LossSaleQuantity;
                lineItem.BackOrderQuantity = lineItem.Quantity - (command.LossSaleQuantity+command.ApprovedQuantity);
                lineItem.ApprovedQuantity = command.ApprovedQuantity;
                lineItem.LineItemStatusId = (int)MainOrderLineItemStatus.Approved;
                _cokeDataContext.SaveChanges();
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
                _log.Error("AddOrderLineItemCommandHandler exception", ex);
                throw;
            }
        }
 public void Handle(ApproveOrderLineItemCommand command)
 {
     var order = GetOrder();
     var approvedItem = order.AllItems.FirstOrDefault(i => i.Id == command.LineItemId);
     
     if (approvedItem != null)
     {
         approvedItem.LineItemStatus = LineItemStatus.Approved;
         if (approvedItem is ReturnableLineItem) return;
         approvedItem.SaleQuantity = command.ApprovedQuantity;
     }
     else
     {
         order.AllItems.ForEach(i => Console.WriteLine(i.Id));
         //Can't handle this yet without a change to the Hub
         Console.WriteLine("Ignoring line item {0} - {1}", order.OrderReference, command.LineItemId);
     }
 }