示例#1
0
        /// <summary>
        /// Stores key value pair data against a given category, collection and key
        /// </summary>
        /// <param name="category">The category</param>
        /// <param name="collection">The collection</param>
        /// <param name="key">The key value for which to store key data</param>
        /// <param name="data">A <see cref="string"/> representing the key data</param>
        /// <param name="keywords">A <see cref="string"/> representing the Keywords associated with the data, these keywords will be used to search the data</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation</returns>
        /// <exception cref="DuplicateKeyException">if a record already exist against category, collection and key</exception>
        public async Task Add(string category, string collection, string key, string data, string keywords)
        {
            if (!await KeyExistsIncludingWarning(category, collection, key))
            {
                await _context.AddAsync(KeyValueData.Create(category, collection, key, data, keywords));

                await _context.SaveChangesAsync();

                _cacheProvider.ClearAllCachedEntries();
            }
        }
示例#2
0
        public async Task <Result <LocalesErrorCodes> > AddAsync(Locale locale)
        {
            await using var context = _contextFactory.CreateDataContext();

            await context.Locales.AddAsync(locale);

            try
            {
                await context.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                if (e.ValueAlreadyExistsException())
                {
                    return(new Result <LocalesErrorCodes>(LocalesErrorCodes.AlreadyExists));
                }

                throw;
            }

            _cacheProvider.ClearAllCachedEntries();
            return(new Result <LocalesErrorCodes>());
        }
示例#3
0
 public void ClearEFGlobalCacheBeforeEachTest()
 {
     _cacheService.ClearAllCachedEntries();
 }