public void SetNotificationAndSyncConfiguration(NotificationAndSyncConfiguration configuration) { var configurationObject = dataContext.Configurations.FirstOrDefault(c => c.Type == EntitiesDb.ConfigurationType.NotificationAndSyncTimePeriods); if (configurationObject == null) { configurationObject = new EntitiesDb.Configuration { Id = 0, Type = EntitiesDb.ConfigurationType.NotificationAndSyncTimePeriods } } ; configurationObject.Content = JsonConvert.SerializeObject(configuration); if (configurationObject.Id == 0) { dataContext.Configurations.Add(configurationObject); } else { dataContext.Configurations.Update(configurationObject); } dataContext.SaveChanges(); }
private void SetTime(EntitiesDb.ConfigurationType configurationType, DateTime dateTime) { var configurationObject = dataContext.Configurations.FirstOrDefault(c => c.Type == configurationType); if (configurationObject == null) { configurationObject = new EntitiesDb.Configuration { Id = 0, Type = configurationType } } ; configurationObject.Content = JsonConvert.SerializeObject(dateTime); if (configurationObject.Id == 0) { dataContext.Configurations.Add(configurationObject); } else { dataContext.Configurations.Update(configurationObject); } dataContext.SaveChanges(); } }