public static string GenerateTransactionDescription( TransactionDirection transactionDirection, ITransactionOwner from, ITransactionOwner to, decimal amount ) { string message = string.Empty; string date = DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss"); switch (transactionDirection) { case TransactionDirection.In: message = string.Format("{0} have sent {1}{2} to you on {3}.", from.TransactionDetailDisplayName, amount, to.AssetsUnit, date); break; case TransactionDirection.Out: message = string.Format("You sent {0}{1} to {2} on {3}", amount, from.AssetsUnit, to.TransactionDetailDisplayName, date); break; default: break; } return(message); }
public List <AccountTransactionDomainEntity> GetLastOutgoingListByTransactionOwner( ITransactionOwner transactionOwner, int itemCount) { return(GetLastItemCountListBy( at => at.FromOwnerType == transactionOwner.OwnerType.ToInt() && at.FromOwnerId == transactionOwner.OwnerId, at => at.TransactionDate, itemCount)); }
public List <AccountTransactionDomainEntity> GetLastOutgoingDateRangeListByTransactionOwner( ITransactionOwner transactionOwner, DateTime startDate, DateTime endDate) { return(GetOrderedDescListBy( at => at.FromOwnerType == transactionOwner.OwnerType.ToInt() && at.FromOwnerId == transactionOwner.OwnerId && at.TransactionDate >= startDate && at.TransactionDate <= endDate, at => at.TransactionDate)); }
public AccountTransactionDomainEntity With( ITransactionOwner from, ITransactionOwner to, decimal amount, TransactionTypeEnum type, TransactionStatusEnum status, ITransactionOwner transactionOwner) { var transactionType = coreContext.Query <ITransactionTypeRepository>() .GetByKey(type.ToString()); var transactionStatus = coreContext.Query <ITransactionStatusRepository>() .GetByKey(status.ToString()); return(With(from, to, amount, transactionType, transactionStatus, transactionOwner)); }
private AccountTransactionDomainEntity With( ITransactionOwner from, ITransactionOwner to, decimal amount, TransactionTypeDomainEntity transactionType, TransactionStatusDomainEntity transactionStatus, ITransactionOwner transactionOwner) { Amount = amount; TransactionType = transactionType; TransactionStatus = transactionStatus; FromTransactionOwner = from; ToTransactionOwner = to; TransactionOwner = transactionOwner; return(this); }
private ITransactionOwner GetTransactionOwner(int?ownerType, int?ownerId) { if (ownerType == null || ownerId == null) { return(null); } ITransactionOwner transactionOwner = null; if (ownerType == TransactionOwnerType.Account.ToInt()) { transactionOwner = coreContext.Query <IAccountRepository>().GetById(ownerId.Value); } else if (ownerType == TransactionOwnerType.CreditCard.ToInt()) { transactionOwner = coreContext.Query <ICreditCardRepository>().GetById(ownerId.Value); } return(transactionOwner); }
private CreditCardDomainEntity DoCreditCardPayment(CreditCardDomainEntity creditCard, decimal amount, int instalmentCount, ITransactionOwner toTransactionOwner) { creditCard.DoPayment(amount); var transaction = coreContext.New <AccountTransactionDomainEntity>() .With(creditCard, toTransactionOwner, amount, TransactionTypeEnum.CreditCardPayment, TransactionStatusEnum.InProgress, creditCard); transaction.Insert(); var transactionDetailIn = transaction.CreateTransactionDetail(TransactionDirection.In); transactionDetailIn.Insert(); var transactionDetailOut = transaction.CreateTransactionDetail(TransactionDirection.Out); transactionDetailOut.Insert(); decimal instalmentAmount = amount / instalmentCount; for (int instalmentIndex = 1; instalmentIndex <= instalmentCount; instalmentIndex++) { string paymentDescription = string.Format("{0} - {1}{2} ({3} instalment)", toTransactionOwner.TransactionDetailDisplayName, instalmentAmount, toTransactionOwner.AssetsUnit, string.Format("{0}/{1}", instalmentIndex, instalmentCount)); DateTime instalmentDate = transaction.TransactionDate.AddMonths(instalmentIndex - 1); var creditCardPayment = coreContext.New <CreditCardPaymentDomainEntity>() .With( instalmentIndex, instalmentAmount, paymentDescription, transaction.TransactionDate, instalmentDate, transaction); creditCardPayment.Insert(); } creditCard.Save(); return(creditCard); }
ICreditCardInfo ICreditCardManager.DoCreditCardPayment(int creditCardId, decimal amount, int instalmentCount, ITransactionOwner toTransactionOwner) { return(DoCreditCardPayment(creditCardId, amount, instalmentCount, toTransactionOwner)); }
internal CreditCardDomainEntity DoCreditCardPayment(int creditCardId, decimal amount, int instalmentCount, ITransactionOwner toTransactionOwner) { var creditCard = GetCreditCardById(creditCardId); return(DoCreditCardPayment(creditCard, amount, instalmentCount, toTransactionOwner)); }