/// <summary> /// 주어진 결제 정보를 업데이트합니다. /// </summary> /// <param name="payment">결제</param> public void Update(Payment payment) { payments.AddOrUpdate( payment.TransactionId, payment, (transactionId, old) => payment); }
/// <summary> /// 주어진 결제를 새로 저장합니다. /// </summary> /// <param name="payment">결제</param> /// <exception cref="DuplicatedKeyException">해당 결제의 TransactionId가 이미 저장되어 있습니다.</exception> public void Add(Payment payment) { if (!payments.TryAdd(payment.TransactionId, payment)) { throw new DuplicatedKeyException($"Duplicated transaction id {payment.TransactionId} detected."); } }