Пример #1
0
        /// <summary>
        /// The OnGetDownloadAsync method allows you to download the file associated with the resource
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnGetDownloadAsync(int id)
        {
            //Uses the GetDocumentAsync function from the applicationdbcontext file to query the database for the document
            var document = await _context.GetDocumentAsync(id);

            //Downlaods the file to your computer based on the File function.
            return(File(document.File, document.FileType, document.Name));
        }
Пример #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var documentID = id.GetValueOrDefault();

            Document = await _context.GetDocumentAsync(documentID);

            if (Document == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #3
0
        public async Task <IActionResult> OnGetDownloadAsync(int id)
        {
            var resource = await _context.Resource.Include(m => m.Documents).Where(m => m.ResourceID == id).FirstOrDefaultAsync();

            var resourceDocument = resource.Documents.FirstOrDefault();
            var document         = await _context.GetDocumentAsync(Convert.ToInt32(resourceDocument.DocumentID));

            return(File(document.File, document.FileType, document.Name));
        }
Пример #4
0
        public async Task <IActionResult> OnGetDocumentAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var documentID = id.GetValueOrDefault();
            var document   = await _context.GetDocumentAsync(documentID);

            return(File(document.File, document.FileType, document.Name));
        }