Ejemplo n.º 1
0
        public void Update(AlbumSettings settings, IUnitOfWork unitOfWork = null)
        {
            AlbumPhotoCollection albumPhotoCollection = GetAlbumPhotoCollection(settings);
            IUnitOfWork          localUnitOfWork      = unitOfWork == null?_unitOfWorkFactory.CreateUnitOfWork() : null;

            try
            {
                IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork ?? localUnitOfWork);
                dbm.SetSQL(_sqlManager.GetSql("Sql.UpdateAlbum.sql"));
                dbm.AddParameter("@TenantId", FieldType.BigInt, settings.TenantId);
                dbm.AddParameter("@ElementId", FieldType.BigInt, settings.ElementId);
                dbm.AddParameter("@DisplayName", FieldType.NVarChar, 256, settings.DisplayName ?? (object)DBNull.Value);
                dbm.AddTypedParameter("@AlbumPhotos", FieldType.Structured, albumPhotoCollection.Count == 0 ? null : albumPhotoCollection, "element.AlbumPhotoTableType");
                dbm.ExecuteNonQuery();
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Commit();
                }
            }
            catch
            {
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Rollback();
                }
                throw;
            }
            finally
            {
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        private AlbumPhotoCollection GetAlbumPhotoCollection(AlbumSettings settings)
        {
            AlbumPhotoCollection albumPhotoCollection = new AlbumPhotoCollection();

            foreach (AlbumPhoto photo in settings.Photos)
            {
                albumPhotoCollection.Add(photo);
            }
            return(albumPhotoCollection);
        }