public void Execute(AddReceiptLineItemCommand command) { _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); try { bool already_Exist = _documentRepository.GetById(command.DocumentId) != null; if (!already_Exist) return; Receipt r = _documentRepository.GetById(command.DocumentId) as Receipt; ReceiptLineItem li = new ReceiptLineItem(command.LineItemId); li.LineItemSequenceNo = command.LineItemSequenceNo; li.Value = command.Value; li.Description = command.Description; li.PaymentType = (PaymentMode) command.PaymentTypeId; li.PaymentRefId = command.PaymentTypeReference; li.LineItemType = (OrderLineItemType)command.LineItemType; li.MMoneyPaymentType = command.MMoneyPaymentType; li.PaymentDocLineItemId = command.PaymentDocLineItemId; li.NotificationId = command.NotificationId; r.Add(li); _documentRepository.Save(r); } catch (Exception ex) { _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); _log.Error("AddReceiptLineItemCommandHandler exception", ex); throw; } }
public void Handle(AddReceiptLineItemCommand command) { var order = GetOrder(); if (order == null) return; var existing = order.Payments.Find(p => p.PaymentReference == command.PaymentTypeReference); if (existing != null) return; var payment = new Payment(order.Id) { PaymentStatus = PaymentStatus.Confirmed, PaymentMode = (PaymentMode) command.LineItemType, PaymentReference = command.PaymentTypeReference, Amount = command.Value }; order.Payments.Add(payment); }
public static void CheckReceiptLineItem(Order order, AddReceiptLineItemCommand addReceiptLineItem) { Assert.AreEqual(order.Payments[0].PaymentMode, (PaymentMode)addReceiptLineItem.PaymentTypeId); Assert.AreEqual(order.TotalValueIncludingVat, addReceiptLineItem.Value); }