Пример #1
0
        /// <summary>
        /// Loads the set of MIME types from the data store. These MIME types are the master list of MIME types and are not
        /// specific to a particular gallery. That is, the <see cref="IMimeType.GalleryId" /> property is set to <see cref="Int32.MinValue" />
        /// and the <see cref="IMimeType.AllowAddToGallery" /> property is <c>false</c> for all items.
        /// </summary>
        /// <returns>Returns a <see cref="IMimeTypeCollection" /> containing MIME types..</returns>
        /// <exception cref="BusinessException">Thrown when no records were found in the master list of MIME types in the data store.</exception>
        private static IMimeTypeCollection LoadMimeTypesFromDataStore()
        {
            IMimeTypeCollection baseMimeTypes = new MimeTypeCollection();

            using (var repo = new MimeTypeRepository())
            {
                foreach (var mimeTypeDto in repo.GetAll().OrderBy(m => m.FileExtension))
                {
                    baseMimeTypes.Add(new MimeType(mimeTypeDto.MimeTypeId, Int32.MinValue, Int32.MinValue, mimeTypeDto.FileExtension.Trim(), mimeTypeDto.MimeTypeValue.Trim(), mimeTypeDto.BrowserMimeTypeValue.Trim(), false));
                }
            }

            if (baseMimeTypes.Count == 0)
            {
                throw new BusinessException("No records were found in the master list of MIME types in the data store.");
            }

            return(baseMimeTypes);
        }
Пример #2
0
        /// <summary>
        /// Loads the set of MIME types from the data store. These MIME types are the master list of MIME types and are not
        /// specific to a particular gallery. That is, the <see cref="IMimeType.GalleryId" /> property is set to <see cref="Int32.MinValue" />
        /// and the <see cref="IMimeType.AllowAddToGallery" /> property is <c>false</c> for all items.
        /// </summary>
        /// <returns>Returns a <see cref="IMimeTypeCollection" /> containing MIME types..</returns>
        /// <exception cref="BusinessException">Thrown when no records were found in the master list of MIME types in the data store.</exception>
        private static IMimeTypeCollection LoadMimeTypesFromDataStore()
        {
            IMimeTypeCollection baseMimeTypes = new MimeTypeCollection();

            using (var repo = new MimeTypeRepository())
            {
                foreach (var mimeTypeDto in repo.GetAll().OrderBy(m => m.FileExtension))
                {
                    baseMimeTypes.Add(new MimeType(mimeTypeDto.MimeTypeId, Int32.MinValue, Int32.MinValue, mimeTypeDto.FileExtension.Trim(), mimeTypeDto.MimeTypeValue.Trim(), mimeTypeDto.BrowserMimeTypeValue.Trim(), false));
                }
            }

            if (baseMimeTypes.Count == 0)
            {
                throw new BusinessException("No records were found in the master list of MIME types in the data store.");
            }

            return baseMimeTypes;
        }