public void SaveProfile(ThemeProfile profile) { ThemeProfileRecord record; if (profile.Id == 0) { record = new ThemeProfileRecord(); Session.Save(record); profile.Id = record.Id; } else { record = Session.Get <ThemeProfileRecord>(profile.Id); } record.Name = profile.Name; record.Description = profile.Description; record.Theme = profile.Theme; record.Settings = SerializeSettings(profile.Settings); record.IsCurrent = profile.IsCurrent; // If the specified profile is marked as current, we need to mark any previous profile to be not current. if (record.IsCurrent) { var previousCurrentProfiles = Session.QueryOver <ThemeProfileRecord>().Where(x => x.IsCurrent && x.Id != record.Id).List(); foreach (var previousCurrentProfile in previousCurrentProfiles) { previousCurrentProfile.IsCurrent = false; } } }
private ThemeProfile Map(ThemeProfileRecord record) { if (record == null) { return(null); } return(new ThemeProfile { Id = record.Id, Name = record.Name, Description = record.Description, Theme = record.Theme, Settings = DeserializeSettings(record.Settings), IsCurrent = record.IsCurrent }); }