/// <summary>
 ///     Changes currency (and amount) of the transaction according to the wallet currency
 /// </summary>
 /// <param name="transaction">Transaction of a changed currency</param>
 /// <param name="walletCurrency">Currency of a wallet, according to this currency will be the transaction currency changed</param>
 /// <returns> same instance of transaction with changed currency</returns>
 public static Transaction ChangeCurrency(Transaction transaction, Currency walletCurrency)
 {
     transaction.Amount = transaction.Amount*
                          ExchangeRateReader.GetExchangeRate(transaction.Currency.Code, walletCurrency.Code);
     transaction.Currency = walletCurrency;
     return transaction;
 }
 public Transaction(Transaction transaction)
 {
     Amount = transaction.Amount;
     Budget = transaction.Budget;
     Category = transaction.Category;
     Currency = transaction.Currency;
     Wallet = transaction.Wallet;
     Guid = transaction.Guid;
     Date = transaction.Date;
     Description = transaction.Description;
 }
        public async Task<bool> AddOrUpdateAsync(Transaction entity)
        {
            if (entity == null)
                throw new ArgumentNullException(nameof(entity));

            var existingTransaction = entity.Guid == Guid.Empty
                ? null
                : await Transactions.FindAsync(entity.Guid);

            Transactions.AddOrUpdate(x => x.Guid, entity);

            await this.SaveChangesAsync();
            return existingTransaction == null;
        }
 public async Task<DeletedEntity<Transaction>> DeteleAsync(Transaction entity)
 {
     await Task.CompletedTask;
     return new DeletedEntity<Transaction>(null);
 }
 public async Task<bool> AddOrUpdateAsync(Transaction entity)
 {
     await Task.CompletedTask;
     return false;
 }
        public async Task<DeletedEntity<Transaction>> DeteleAsync(Transaction entity)
        {
            var transactionToDelete = entity.Guid == Guid.Empty
                ? null
                : await Transactions.FindAsync(entity.Guid);

            var deletedTransaction = transactionToDelete == null
                ? null
                : Transactions.Remove(transactionToDelete);

            await this.SaveChangesAsync();
            return new DeletedEntity<Transaction>(deletedTransaction);
        }
 public void AttachTransaction(Transaction transaction)
 {
     Transactions.Attach(transaction);
 }
 public void AttachTransaction(Transaction transaction)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 ///     Changes currency (and amount) of the transaction according to the wallet currency
 /// </summary>
 /// <param name="transaction">Transaction of a changed currency</param>
 /// <param name="walletCurrency">Currency of a wallet, according to this currency will be the transaction currency changed</param>
 /// <returns> new instance of transaction with changed currency</returns>
 public static Transaction ChangeCurrencyForNewTransaction(Transaction transaction, Currency walletCurrency)
 {
     var newTransaction = new Transaction(transaction);
     return ChangeCurrency(newTransaction, walletCurrency);
 }