예제 #1
0
        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);
        }
예제 #2
0
        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);
        }