public static string GetApplicationInformation(string Key) { using (HqTrustData dbContext = new HqTrustData()) { AnwendungsInformationen info = dbContext.AnwendungsInformationen.FirstOrDefault(a => a.Key == Key); if (info == null) { // if record is not found add Anwndungsinformation-Record info = new AnwendungsInformationen() { Key = Key, Value = string.Empty }; dbContext.AnwendungsInformationen.Add(info); try { dbContext.SaveChanges(); } catch (Exception) { throw new Exception("Fehler beim Eintragen einer AnwendungsInformation"); } } if (info.Value == null) { return(string.Empty); } else { return(info.Value); } } }
public static void SetApplicationInformation(string key, string value) { using (HqTrustData dbContext = new HqTrustData()) { AnwendungsInformationen info = dbContext.AnwendungsInformationen.FirstOrDefault(a => a.Key == key); if (info == null) { info = new AnwendungsInformationen() { Key = key, Value = value }; dbContext.AnwendungsInformationen.Add(info); try { dbContext.SaveChanges(); } catch (Exception) { throw new Exception("Fehler beim Eintragen einer AnwendungsInformation"); } } else { info.Value = value; try { dbContext.SaveChanges(); } catch (Exception) { throw new Exception("Fehler beim Ă„ndern einer AnwendungsInformation"); } } } }