예제 #1
0
        public async Task <StreamFileUploadDatabase> GetSectionEpisodes(Guid id, Guid sub, string category, string section)
        {
            var model = await _context.ClamSectionAcademicSubCategoryItems.AsNoTracking().ToListAsync();

            List <SectionItem> result = new List <SectionItem>();

            foreach (var item in model)
            {
                if (item.SubCategoryId == sub && item.AcademicId == id)
                {
                    result.Add(new SectionItem()
                    {
                        ItemId          = item.ItemId,
                        ItemTitle       = FilePathUrlHelper.GetFileName(item.ItemTitle),
                        ItemPath        = item.ItemPath,
                        ItemDescription = item.ItemDescription,
                        LastModified    = item.LastModified,
                        DateAdded       = item.DateAdded,
                        Size            = item.Size,
                        UrlCategory     = category,
                        UrlSection      = section,
                        UrlSectionItem  = FilePathUrlHelper.UrlString(FilePathUrlHelper.GetFileName(item.ItemTitle))
                    });
                }
            }
            StreamFileUploadDatabase episodes = new StreamFileUploadDatabase()
            {
                SectionItems = result
            };

            episodes.AcademicId    = id;
            episodes.SubCategoryId = sub;
            return(episodes);
        }
예제 #2
0
        // GET: Stream/Create
        public ActionResult Create()
        {
            var model = _context.Set <ClamSectionAcademicSubCategoryItem>().AsNoTracking().ToList();
            List <SectionItem> result = new List <SectionItem>();

            foreach (var item in model)
            {
                result.Add(new SectionItem()
                {
                    ItemId          = item.ItemId,
                    ItemTitle       = item.ItemTitle,
                    ItemDescription = item.ItemDescription,
                    LastModified    = item.LastModified,
                    DateAdded       = item.DateAdded,
                    ItemPath        = item.ItemPath,
                    Size            = item.Size
                });
            }
            StreamFileUploadDatabase test = new StreamFileUploadDatabase()
            {
                SectionItems = result
            };

            return(View(test));
        }
예제 #3
0
        public ActionResult IndexPhysical()
        {
            var contents = _fileProvider.GetDirectoryContents(string.Empty);
            StreamFileUploadDatabase model = new StreamFileUploadDatabase()
            {
                PhysicalFiles = contents
            };

            return(View(model));
        }
예제 #4
0
        public async Task <IActionResult> Create(StreamFileUploadDatabase model)
        {
            // Perform an initial check to catch FileUpload class
            // attribute violations.
            if (!ModelState.IsValid)
            {
                _uploadContent.Result = "Please correct the form.";

                return(View());
            }

            var formFileContent =
                await FileHelpers.ProcessFormFile <StreamFileUploadDatabase>(
                    model.FormFile, ModelState, _permittedExtentions,
                    _fileSizeLimit);

            // Perform a second check to catch ProcessFormFile method
            // violations. If any validation check fails, return to the
            // page.
            if (!ModelState.IsValid)
            {
                _uploadContent.Result = "Please correct the form.";

                return(View());
            }

            // **WARNING!**
            // In the following example, the file is saved without
            // scanning the file's contents. In most production
            // scenarios, an anti-virus/anti-malware scanner API
            // is used on the file before making the file available
            // for download or for use by other systems.
            // For more information, see the topic that accompanies
            // this sample.

            var file = new ClamSectionAcademicSubCategoryItem
            {
                ItemPath        = null,
                ItemTitle       = model.FormFile.FileName,
                ItemDescription = model.Note,
                Size            = model.FormFile.Length,
                SubCategoryId   = new Guid("8d7af8fa-4659-4aef-1746-08d7d7789232")
                                  //AcademicId = new Guid("a7e95d01-3a1c-474c-d5ab-08d7d76073f2")
            };

            _context.Set <ClamSectionAcademicSubCategoryItem>().Add(file);
            //_context.Entry(file).State = EntityState.Modified;
            _context.SaveChanges();
            //await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #5
0
        public AcademiaStreamController(ClamUserAccountContext context, IConfiguration config, StreamFileUploadDatabase uploadFile,
                                        StreamFileData uploadContent, ILogger <AcademiaStreamController> logger, IFileProvider fileProvider)
        {
            //_fileProvider = fileProvider;
            _uploadFile    = uploadFile;
            _uploadContent = uploadContent;
            _context       = context;
            _logger        = logger;
            _fileProvider  = fileProvider;

            // Physical Store Provider
            _targetFilePath   = config.GetValue <string>("AbsoluteRootFilePathStore");
            _targetFolderPath = config.GetValue <string>("AbsoluteFilePath-Acad");
            _fileSizeLimit    = config.GetValue <long>("FileSizeLimit");
        }