protected virtual Entities.Tenant.AutoBookApi.AutoBookSettings GetEntity() { if (_cachedAutoBookSettings == null) { _cachedAutoBookSettings = _dbContext .Query <Entities.Tenant.AutoBookApi.AutoBookSettings>().FirstOrDefault(); } return(_cachedAutoBookSettings); }
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; }
public void SaveChanges() { _dbContext.SaveChanges(); _cachedAutoBookSettings = null; }