/// <summary>
        /// Gets all available content in the specified folder.
        /// </summary>
        /// <param name="api">The current api</param>
        /// <param name="folderId">The optional folder id</param>
        /// <param name="type">The optional media type</param>
        /// <returns>The model</returns>
        public static MediaListModel Get(IApi api, Guid?folderId = null, MediaType?type = null)
        {
            var model = new MediaListModel()
            {
                CurrentFolderId = folderId,
                ParentFolderId  = null,
                Filter          = type
            };

            if (folderId.HasValue)
            {
                var folder = api.Media.GetFolderById(folderId.Value);
                if (folder != null)
                {
                    model.ParentFolderId = folder.ParentId;
                }
            }
            model.Media = api.Media.GetAll(folderId).ToList();

            if (type.HasValue)
            {
                model.Media = model.Media.Where(m => m.Type == type.Value).ToList();
            }

            var structure = api.Media.GetStructure();

            model.Folders    = structure.GetPartial(folderId);
            model.Breadcrumb = structure.GetBreadcrumb(folderId);

            return(model);
        }
Example #2
0
        /// <summary>
        /// Gets all available content in the specified folder.
        /// </summary>
        /// <param name="api">The current api</param>
        /// <param name="folderId">The optional folder id</param>
        /// <returns>The model</returns>
        public static MediaListModel Get(Api api, string folderId = null)
        {
            var model = new MediaListModel()
            {
                CurrentFolderId = folderId,
                ParentFolderId  = null
            };

            var folder = api.Media.GetFolderById(folderId);

            if (folder != null)
            {
                model.ParentFolderId = folder.ParentId;
            }

            model.Media = api.Media.GetAll(folderId).ToList();

            var structure = api.Media.GetStructure();

            model.Folders    = structure.GetPartial(folderId);
            model.Breadcrumb = structure.GetBreadcrumb(folderId);

            return(model);
        }