private SettingResult AddOrUpdate(Setting Setting) { var result = new SettingResult { Setting = Setting }; try { var setting = Setting.ToEntities(); if (setting.SettingId == -1) { cusRelContext.Settings.Attach(setting); cusRelContext.Settings.Remove(setting); } else { cusRelContext.Settings.AddOrUpdate(setting); } var count = SaveChanges(); if (count > 0) { result.SetOK(); } } catch (Exception e) { result.SetFail(e); } return(result); }
public SettingResult SaveSetting(Setting Setting) { try { InitCusRelContext(); var result = AddOrUpdate(Setting); // Implement distributed cache instead since this application will be load balanced //if (DomainCache.GetCache(_THISCONTEXTCACHEKEYNAME) != null) // DomainCache.Remove(_THISCONTEXTCACHEKEYNAME); return(result); } catch (Exception e) { var result = new SettingResult(); result.SetFail(e); return(result); } }