public void SaveFor(IClassifiable entity, SettingsEntity settings)
 {
     if (settings != null)
     {
         settingsRepo.SaveOrUpdateFor(entity, settings);
     }
 }
 public SettingsEntryEntity GetEntryByKey(SettingsEntity entity, string key)
 {
     using (var wu = SessionManager.WorkUnitFor(this, DbWorkUnitType.Read))
     {
         return(AsQueryable(wu.Session)
                .Where(x => x.Settings == entity && x.Name == key)
                .FirstOrDefault());
     }
 }
        public void BoxOfSettingsEntityTest()
        {
            IContainer container = Container;
            var repo = container.Resolve<SettingsRepository>();
            var s = repo.Get(1);
            if (s == null)
            {
                s = new SettingsEntity() { Name = "testsetting" };
                s.AddEntry("asd","ddd");
                repo.Save(s);
            }

            var transformer = container.Resolve<NHibernateBoxTransformation<SettingsBoxMap, SettingsEntity>>();
            transformer.Entries = new[] {s};
            var boxed = transformer.ToBox();
            var xmlBoxer = new XmlBoxPresentation<SettingsBoxMap>();
            var ss = xmlBoxer.AsString(boxed);
            var box = xmlBoxer.FromString(ss);
            Assert.IsTrue(box.First().Name == s.Name);
            Assert.AreEqual(s.Entries.First().Name, box.First().Entries.First().Name);
        }
        public void TestSettingsProperties()
        {
            var settingsRepo = Container.Resolve<SettingsRepository>();
            var entryRepo = Container.Resolve<SettingsEntryRepository>();

            var datetime = DateTime.Now;

            var settings = new SettingsEntity("testSettingProps");
            settings.SetEntry("str", "stringvalue");
            settings.SetEntry("int", 10);
            settings.SetEntry("double", 10.4);
            settings.SetEntry("bit", true);
            settings.SetEntry("date", datetime);
            settingsRepo.SaveOrUpdate(settings);

            var e = entryRepo.GetEntryByKey(settings, "str");
            settings = settingsRepo.Load(settings.Id);
            Assert.IsNotNull(settings);

            var date = settings["date"].GetValue<DateTime>();
            Assert.AreEqual(datetime.ToString(), date.ToString());
        }
 public void UpdatePersistent(SettingsEntity settings)
 {
     settingsRepo.Update(settings);
 }