Beispiel #1
0
        public IActionResult Enrollments()
        {
            var context = new GrandCircusLmsExampleContext();
            var data    = context.Enrollments.Where(x => x.CourseId == 1).Include(y => y.Student).ToList();

            return(View());
        }
        public IActionResult Index()
        {
            List <Location> locations = new List <Location>();

            using (var context = new GrandCircusLmsExampleContext())
            {
                locations = context.Locations.ToList();
            }
            return(View(locations));
        }
Beispiel #3
0
 public IActionResult Index()
 {
     using (var context = new GrandCircusLmsExampleContext())
     {
         var data = context.Instructors
                    .Include(x => x.InstructorCourses).ThenInclude(y => y.Course)
                    .ToList();
         return(View(data));
     }
 }
        // GET: Students
        public IActionResult Index()
        {
            List <Student> students = new List <Student>();

            using (var context = new GrandCircusLmsExampleContext())
            {
                students = context.Students.ToList();
            }
            return(View(students));
        }
Beispiel #5
0
        public IActionResult Create(string lastName, string courseName)
        {
            var context    = new GrandCircusLmsExampleContext();
            var instructor = context.Instructors.Where(x => x.LastName == lastName).FirstOrDefault();
            var course     = context.Courses.Where(c => c.Name == courseName).FirstOrDefault();

            instructor.InstructorCourses = new List <InstructorCourse>
            {
                new InstructorCourse
                {
                    Instructor = instructor,
                    Course     = course
                }
            };
            context.Instructors.Update(instructor);
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public IActionResult Update()
        {
            var context  = new GrandCircusLmsExampleContext();
            var location = context.Locations.FirstOrDefault();

            location.Name = "My House";
            var course    = context.Courses.Find(2);
            var newCourse = new Course
            {
                Name    = "Example",
                Credits = 2
            };

            context.Update(location);
            context.Remove(course);
            context.Add(newCourse);
            context.SaveChanges();

            return(View());
        }
Beispiel #7
0
 public CoursesController(GrandCircusLmsExampleContext context)
 {
     _context = context;
 }
 public StudentsController(GrandCircusLmsExampleContext context)
 {
     //_context = context;
 }