/// <summary> /// The OnGetAsync method finds the related resource and document and course related to the resource /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> OnGetAsync(int?id) { //Checks to see if passed in id is null if (id == null) { return(NotFound()); } //Uses the GetResourceAsync function from the applicationdbcontext file to query the database for the resource based off of the id passed in. Resource = await _context.GetResourceAsync(id.GetValueOrDefault()); //Quereis the database for the last document uploaded for that resource Document = await _context.Document .Where(d => d.Resource.ResourceID == id) .OrderByDescending(d => d.UploadDate) .FirstOrDefaultAsync(); //checks to see if the resource is null if (Resource == null) { return(NotFound()); } return(Page()); }