コード例 #1
0
        private void ClearCacheTransactions()
        {
            List <string> transactionsCached = _cache.KeyValues().Where(x => x.Contains(KEY_CACHE_TRANSACTION_YEAR_MONTH))
                                               .ToList();

            foreach (string transactionKeyCacheAux in transactionsCached)
            {
                _cache.ClearValues(transactionKeyCacheAux);
            }
        }
コード例 #2
0
        public async Task <int> AddTransactionCode(CodeTransactionDTO codeTransactionDTO)
        {
            _cache.ClearValues(KEY_CACHE_CODES);

            string transactionCodeFormat = codeTransactionDTO.Code.ToUpperInvariant().Trim();

            HashSet <string> codesAvailables = this._contextDB.MCodeTransaction.Select(x => x.Code).ToHashSet();

            if (codesAvailables.Contains(transactionCodeFormat))
            {
                throw new Exception($"The code {transactionCodeFormat} already exist!");
            }

            MCodeTransaction mCodeTransaction = new MCodeTransaction()
            {
                Code = transactionCodeFormat
            };

            await this._contextDB.MCodeTransaction.AddAsync(mCodeTransaction);

            await this._contextDB.Context.SaveChangesAsync();

            return(mCodeTransaction.ID);
        }