private static Receipt CreateRefundReceipt(ProductReceiptEntity entity) { return(new RefundReceipt { Id = entity.id, Time = entity.externalTransactionTime, ExternalTransactionId = entity.externalTransactionId, ExternalTransactionTime = entity.externalTransactionTime, }); }
public static Receipt Map(this ProductReceiptEntity entity) { switch ((ReceiptType)entity.type) { case ReceiptType.CreditCard: return(CreateCreditCardReceipt(entity)); default: return(CreateRefundReceipt(entity)); } }
private static Receipt CreateCreditCardReceipt(ProductReceiptEntity entity) { return(new CreditCardReceipt { Id = entity.id, Time = entity.externalTransactionTime, ExternalTransactionId = entity.externalTransactionId, ExternalTransactionTime = entity.externalTransactionTime, CreditCard = new CreditCardSummary { Pan = entity.creditCardPan, Type = (CreditCardType)entity.creditCardType, } }); }
public static ProductReceiptEntity Map(this Receipt receipt, Guid orderId) { var type = GetReceiptType(receipt); var entity = new ProductReceiptEntity { id = receipt.Id, orderId = orderId, time = receipt.Time, externalTransactionId = receipt.ExternalTransactionId, externalTransactionTime = receipt.ExternalTransactionTime, type = (int)type, }; switch (type) { case ReceiptType.CreditCard: ((CreditCardReceipt)receipt).MapTo(entity); break; } return(entity); }
private static void MapTo(this CreditCardReceipt receipt, ProductReceiptEntity entity) { entity.creditCardPan = receipt.CreditCard.Pan; entity.creditCardType = (int?)receipt.CreditCard.Type; }