示例#1
0
        protected virtual Entities.Tenant.AutoBookApi.AutoBookSettings GetEntity()
        {
            if (_cachedAutoBookSettings == null)
            {
                _cachedAutoBookSettings = _dbContext
                                          .Query <Entities.Tenant.AutoBookApi.AutoBookSettings>().FirstOrDefault();
            }

            return(_cachedAutoBookSettings);
        }
示例#2
0
        public void AddOrUpdate(AutoBookSettings autoBookSettings)
        {
            var currentEntity = GetEntity();

            if (currentEntity == null)
            {
                currentEntity = _mapper.Map <Entities.Tenant.AutoBookApi.AutoBookSettings>(autoBookSettings);
                _dbContext.Add(currentEntity, post => post.MapTo(autoBookSettings), _mapper);
            }
            else
            {
                _mapper.Map(autoBookSettings, currentEntity);
                _dbContext.Update(currentEntity, post => post.MapTo(autoBookSettings), _mapper);
            }

            _cachedAutoBookSettings = currentEntity;
        }
示例#3
0
 public void SaveChanges()
 {
     _dbContext.SaveChanges();
     _cachedAutoBookSettings = null;
 }