public async Task <IEnumerable <CustomerFee> > SaveAsync(IEnumerable <CustomerFee> fees, CancellationToken token = default(CancellationToken)) { using (var scope = transactionScopeBuilder.Create()) { var result = new List <CustomerFee>(); var fee1st = fees.First(); var customerId = fee1st.CustomerId; var currencyId = fee1st.CurrencyId; foreach (var fee in fees.Where(f => f.Fee != null && f.Fee != f.NewFee)) { await deleteCustomerFeeQueryProcessor.DeleteAsync(new CustomerFeeSearch { CustomerId = customerId, CurrencyId = currencyId, Fee = fee.Fee.Value, }, token); } foreach (var fee in fees.Where(f => f.Fee != f.NewFee && f.NewFee != 0)) { fee.Fee = fee.NewFee; result.Add(await addCustomerFeeQueryProcessor.SaveAsync(fee, token)); } scope.Complete(); return(result); } }
private async Task SaveBankTransferFeeAsync(int customerId, int paymentAgencyId, int currencyId, decimal bankFee, DateTime updateAt, int loginUserId, CancellationToken token = default(CancellationToken)) { if (bankFee == 0M) { return; } if (customerId != 0) { var fee = new CustomerFee(); fee.CustomerId = customerId; fee.CurrencyId = currencyId; fee.Fee = bankFee; fee.NewFee = bankFee; fee.UpdateAt = updateAt; fee.CreateAt = updateAt; fee.CreateBy = loginUserId; fee.UpdateBy = loginUserId; await addCustomerFeeQueryProcessor.SaveAsync(fee, token); } if (paymentAgencyId != 0) { var fee = new PaymentAgencyFee(); fee.PaymentAgencyId = paymentAgencyId; fee.CurrencyId = currencyId; fee.Fee = bankFee; fee.NewFee = bankFee; fee.UpdateAt = updateAt; fee.CreateAt = updateAt; fee.CreateBy = loginUserId; fee.UpdateBy = loginUserId; await addPaymentAgencyFeeQueryProcessor.SaveAsync(fee, token); } }
private async Task SaveBankTransferFeeAsync(Collation collation, CollationSearch option, DateTime updateAt, CancellationToken token = default(CancellationToken)) { if (collation.CustomerId > 0) { var fee = new CustomerFee { CustomerId = collation.CustomerId, CurrencyId = collation.CurrencyId, Fee = collation.BankTransferFee, NewFee = collation.BankTransferFee, UpdateAt = updateAt, CreateAt = updateAt, CreateBy = option.LoginUserId, UpdateBy = option.LoginUserId, }; await addCustomerFeeQueryProcessor.SaveAsync(fee, token); } if (collation.PaymentAgencyId > 0) { var fee = new PaymentAgencyFee { PaymentAgencyId = collation.PaymentAgencyId, CurrencyId = collation.CurrencyId, Fee = collation.BankTransferFee, NewFee = collation.BankTransferFee, UpdateAt = updateAt, CreateAt = updateAt, CreateBy = option.LoginUserId, UpdateBy = option.LoginUserId, }; await addPaymentAgencyFeeQueryProcessor.SaveAsync(fee, token); } }