/// <summary> /// Updates the course resources. /// </summary> /// <param name="course">The course.</param> private void UpdateCourseResources(Course course) { if (course == null) { return; } CourseResources.Clear(); foreach (var r in course.Resources) { CourseResources.Add(new Resource { ResourceId = r.ResourceId, Name = r.Name, Link = r.Link }); } }
public async Task <IActionResult> OnGetAsync(int?id) { int ID = (int)id; CurrentCourse = await courseDbContext.Courses.SingleOrDefaultAsync(m => m.ID == ID); if (CurrentCourse != null) { var tempList = await courseResourceDbContext.Resources.ToListAsync(); foreach (var resource in tempList) { if (resource.CourseID == ID) { CourseResources.Add(resource); } } return(Page()); } else { return(RedirectToPage("/NotFound")); } }
/// <summary> /// Adds the resource. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void AddResource(object sender, RoutedEventArgs e) => CourseResources.Add(new Resource { Name = "New Resource" });