public async Task <List <GetTransactionLogForViewDto> > GetTransactionLogByTransId(int inId, int outId) { var output = new List <GetTransactionLogForViewDto>(); var transactionLogs = _transactionLogRepository.GetAll().Where(x => x.TransactionId == inId || x.TransactionId == outId).ToList(); foreach (var transactionLog in transactionLogs) { var transactionToAdd = new GetTransactionLogForViewDto { TransactionLog = ObjectMapper.Map <TransactionLogDto>(transactionLog) }; if (transactionToAdd.TransactionLog.TransactionId != null) { var _lookupTransaction = await _lookup_transactionRepository.FirstOrDefaultAsync((int)transactionToAdd.TransactionLog.TransactionId.Value); transactionToAdd.TransactionTransaction_Date = _lookupTransaction.Transaction_Date.ToString(); } if (transactionToAdd.TransactionLog.ActionBy != null) { var _lookupUser = await _lookup_userRepository.FirstOrDefaultAsync((long)transactionToAdd.TransactionLog.ActionBy); transactionToAdd.UserName = _lookupUser.Name.ToString(); } if (transactionToAdd.TransactionLog.NewValue == transactionToAdd.TransactionLog.OldValue) { transactionToAdd.TransactionLog.HasDifferent = true; } output.Add(transactionToAdd); } return(output); }
public async Task <GetTransactionLogForViewDto> GetTransactionLogForView(int id) { var transactionLog = await _transactionLogRepository.GetAsync(id); var output = new GetTransactionLogForViewDto { TransactionLog = ObjectMapper.Map <TransactionLogDto>(transactionLog) }; if (output.TransactionLog.TransactionId != null) { var _lookupTransaction = await _lookup_transactionRepository.FirstOrDefaultAsync((int)output.TransactionLog.TransactionId); output.TransactionTransaction_Date = _lookupTransaction.Transaction_Date.ToString(); } if (output.TransactionLog.ActionBy != null) { var _lookupUser = await _lookup_userRepository.FirstOrDefaultAsync((long)output.TransactionLog.ActionBy); output.UserName = _lookupUser.Name.ToString(); } return(output); }