public void Add(ABPageSetting item) { if (null != item) { UpdateOrAdd(item, item); } }
public ABPageSetting Get(ABPageSetting dummy) { return _dbContext.ABPageSettings.Where(it => it.UUID.Equals(dummy.UUID, StringComparison.OrdinalIgnoreCase) && it.SiteName.Equals(dummy.Site.FullName, StringComparison.OrdinalIgnoreCase)) .ToList() .Select(it => it.ToABPageSetting()).FirstOrDefault(); }
public void Update(ABPageSetting @new, ABPageSetting old) { UpdateOrAdd(@new, old); }
private void UpdateOrAdd(ABPageSetting item, ABPageSetting oldItem) { ((IPersistable)item).OnSaving(); var dummy = _dbContext.ABPageSettings.FirstOrDefault(it => it.UUID.Equals(oldItem.UUID, StringComparison.OrdinalIgnoreCase) && it.SiteName.Equals(oldItem.Site.FullName, StringComparison.OrdinalIgnoreCase)); if (null != dummy) { item.ToABPageSettingEntity<ABPageSettingEntity>(dummy); } else { dummy = item.ToABPageSettingEntity<ABPageSettingEntity>(); _dbContext.ABPageSettings.Add(dummy); } _dbContext.SaveChanges(); ((IPersistable)item).OnSaved(); }
public void Remove(ABPageSetting item) { ((IPersistable)item).OnSaving(); var dummy = _dbContext.ABPageSettings.FirstOrDefault(it => it.UUID.Equals(item.UUID, StringComparison.OrdinalIgnoreCase) && it.SiteName.Equals(item.Site.FullName, StringComparison.OrdinalIgnoreCase)); if (null != dummy) { _dbContext.ABPageSettings.Remove(dummy); _dbContext.SaveChanges(); } ((IPersistable)item).OnSaved(); }