public IAppliedPayment BuildEntity(AppliedPaymentDto dto) { var transaction = new AppliedPayment( dto.PaymentKey, dto.InvoiceKey, dto.AppliedPaymentTfKey) { Key = dto.Key, Description = dto.Description, Amount = dto.Amount, Exported = dto.Exported, UpdateDate = dto.UpdateDate, CreateDate = dto.CreateDate }; transaction.ResetDirtyProperties(); return(transaction); }
/// <summary> /// The create applied payment with key. /// </summary> /// <param name="paymentKey"> /// The payment key. /// </param> /// <param name="invoiceKey"> /// The invoice key. /// </param> /// <param name="appliedPaymentTfKey"> /// The applied payment tf key. /// </param> /// <param name="description"> /// The description. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="raiseEvents"> /// The raise events. /// </param> /// <returns> /// The <see cref="IAppliedPayment"/>. /// </returns> internal IAppliedPayment CreateAppliedPaymentWithKey(Guid paymentKey, Guid invoiceKey, Guid appliedPaymentTfKey, string description, decimal amount, bool raiseEvents = true) { Mandate.ParameterCondition(!Guid.Empty.Equals(paymentKey), "paymentKey"); Mandate.ParameterCondition(!Guid.Empty.Equals(invoiceKey), "invoiceKey"); Mandate.ParameterCondition(!Guid.Empty.Equals(appliedPaymentTfKey), "appliedPaymentTfKey"); var appliedPayment = new AppliedPayment(paymentKey, invoiceKey, appliedPaymentTfKey) { Description = description, Amount = amount, Exported = false }; if (raiseEvents) { if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs <IAppliedPayment>(appliedPayment), this)) { appliedPayment.WasCancelled = true; return(appliedPayment); } } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateAppliedPaymentRepository(uow)) { repository.AddOrUpdate(appliedPayment); uow.Commit(); } } if (raiseEvents) { Created.RaiseEvent(new Events.NewEventArgs <IAppliedPayment>(appliedPayment), this); } return(appliedPayment); }
/// <summary> /// The create applied payment with key. /// </summary> /// <param name="paymentKey"> /// The payment key. /// </param> /// <param name="invoiceKey"> /// The invoice key. /// </param> /// <param name="appliedPaymentTfKey"> /// The applied payment tf key. /// </param> /// <param name="description"> /// The description. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="raiseEvents"> /// The raise events. /// </param> /// <returns> /// The <see cref="IAppliedPayment"/>. /// </returns> internal IAppliedPayment CreateAppliedPaymentWithKey(Guid paymentKey, Guid invoiceKey, Guid appliedPaymentTfKey, string description, decimal amount, bool raiseEvents = true) { Mandate.ParameterCondition(!Guid.Empty.Equals(paymentKey), "paymentKey"); Mandate.ParameterCondition(!Guid.Empty.Equals(invoiceKey), "invoiceKey"); Mandate.ParameterCondition(!Guid.Empty.Equals(appliedPaymentTfKey), "appliedPaymentTfKey"); var appliedPayment = new AppliedPayment(paymentKey, invoiceKey, appliedPaymentTfKey) { Description = description, Amount = amount, Exported = false }; if (raiseEvents) if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs<IAppliedPayment>(appliedPayment), this)) { appliedPayment.WasCancelled = true; return appliedPayment; } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateAppliedPaymentRepository(uow)) { repository.AddOrUpdate(appliedPayment); uow.Commit(); } } if (raiseEvents) Created.RaiseEvent(new Events.NewEventArgs<IAppliedPayment>(appliedPayment), this); return appliedPayment; }