public bool SaveMood(Mood mood) { bool result = false; ISession session = SessionFactory.GetSession(); ITransaction tx = session.BeginTransaction(); try { EntityConverter converter = new EntityConverter(); MoodEntity dataEntity = converter.FromBusinessEntity(mood); session.SaveOrUpdate(dataEntity); tx.Commit(); mood.ID = dataEntity.ID; result = true; } catch (Exception ex) { Logger.Write(ex); tx.Rollback(); } finally { session.Close(); tx.Dispose(); } return(result); }
public Mood FromDataEntity(MoodEntity dataEntity, MoodConvertOptions options) { if (dataEntity == null) { return(null); } Mood businessEntity = new Mood() { ID = dataEntity.ID, Name = dataEntity.Name, PrivateMarks = dataEntity.PrivateMarks, Comments = dataEntity.Comments, Description = dataEntity.Description }; return(businessEntity); }