Пример #1
0
        public static void ToRow(TranslationVal bean, TranslationRow row)
        {
            if (bean == null)
                return;

            row.CultureId = bean.CultureId;
            row.Key = bean.Key;
            row.Value = bean.Value;
        }
Пример #2
0
        internal static TranslationVal ToBean(TranslationRow row)
        {
            if (row == null)
                return null;

            var bean = new TranslationVal();
            bean.CultureId = row.CultureId;
            bean.Key = row.Key;
            bean.Value = row.Value;
            return bean;
        }
Пример #3
0
        /// <summary>
        /// Create data in database
        /// </summary>
        /// <param name="translation">Data</param>
        /// <returns>insert data</returns>
        public TranslationVal Create(TranslationVal translation)
        {
            if (translation == null || translation.CultureId < 0 || string.IsNullOrWhiteSpace(translation.Key))
                return null;

            var row = new TranslationRow();
            TranslationTransformer.ToRow(translation, row);
            _dbContext.Translation.Add(row);
            _dbContext.SaveChanges();

            return TranslationTransformer.ToBean(row);
        }
Пример #4
0
 public TranslationVal UpdateTranslation(TranslationVal translation)
 {
     TranslationVal result = null;
     //Create data in database
     BeginTransaction();
     try
     {
         result = GetTranslationManager().UpdateTranslation(translation);
         CommitTransaction();
         //invalidate cache
         InvalidateCache(_cacheName);
     }
     catch (Exception exception)
     {
         _logger.LogCritical("Unable to update translation", exception);
         RollbackTransaction();
         throw exception;
     }
     finally
     {
         EndTransaction();
     }
     return result;
 }
Пример #5
0
        /// <summary>
        /// Update data in database
        /// </summary>
        /// <param name="translation">data</param>
        /// <returns>updated data</returns>
        public TranslationVal Update(TranslationVal translation)
        {
            if (translation == null || translation.CultureId < 0 || string.IsNullOrWhiteSpace(translation.Key))
                return null;

            var row = _dbContext.Translation.Where(m => m.CultureId == translation.CultureId && m.Key == translation.Key).FirstOrDefault();
            if (row == null)
            { // No data in database
                return Create(translation);
            }
            else
            { //Modify Data in database
                TranslationTransformer.ToRow(translation, row);
                _dbContext.SaveChanges();

                return TranslationTransformer.ToBean(row);
            }
        }
Пример #6
0
 internal TranslationVal UpdateTranslation(TranslationVal translation)
 {
     return _module.Update(translation);
 }