Example #1
0
        public bool SaveAlbum(Album album)
        {
            bool result = false;

            ISession session = SessionFactory.GetSession();

            ITransaction tx = session.BeginTransaction();

            try
            {
                EntityConverter converter = new EntityConverter();

                AlbumEntity dataEntity = converter.FromBusinessEntity(album);

                session.Merge(dataEntity);

                tx.Commit();

                album.ID = dataEntity.ID;

                result = true;
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                tx.Rollback();
            }
            finally
            {
                session.Close();
                tx.Dispose();
            }

            return(result);
        }
Example #2
0
        public bool SavePlace(Place place)
        {
            bool result = false;

            ISession session = SessionFactory.GetSession();

            ITransaction tx = session.BeginTransaction();

            try
            {
                EntityConverter converter = new EntityConverter();

                PlaceEntity dataEntity = converter.FromBusinessEntity(place);

                session.SaveOrUpdate(dataEntity);

                tx.Commit();

                place.ID = dataEntity.ID;

                result = true;
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                tx.Rollback();
            }
            finally
            {
                session.Close();
                tx.Dispose();
            }

            return(result);
        }