private void ValidateIfExists(BankTransactionRule entity) { var exists = ruleRepository.Table.Any(q => q.Description == entity.Description); if (exists) { throw new Exception(string.Format("Rule for '{0}' already exists.", entity.Description)); } }
private TransactionRule MapToModel(BankTransactionRule table) { return(new TransactionRule() { RuleID = table.RuleID, Description = table.Description, Tag = table.Tag, TagGroup = table.TagGroup, IsTransfer = table.IsTransfer }); }
private void ApplyRuleToExistingTransactions(BankTransactionRule entity) { var transactionList = transactionRepository.Table.Where(q => string.IsNullOrEmpty(q.Tag) && string.IsNullOrEmpty(q.TagGroup) && q.Description.ToUpper().Contains(entity.Description.ToUpper()) ).ToList(); foreach (var transaction in transactionList) { transaction.Tag = entity.Tag; transaction.TagGroup = entity.TagGroup; transaction.IsTransfer = entity.IsTransfer; transactionRepository.Update(transaction); } }