Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("CourseName,ParticipantsAllowed,HandinDeadline,TeacherAUID")] Assignment assignment)
        {
            _context.Add(assignment);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public static async Task <Student> GetStudent(int studentId, BlackboardDbContext context)
        {
            var student = await context.Students.FindAsync(studentId);

            await context.SaveChangesAsync();

            return(student);
        }
        //TODO: Grade assignment
        public static async Task GradeAssignment(Assignment assignment, BlackboardDbContext context)
        {
            var entity = await context.Assignments.FindAsync(assignment.AssignmentId);

            entity.Grade = assignment.Grade;
            context.Update(entity);
            await context.SaveChangesAsync();
        }
        public static async Task <IEnumerable <Student> > GetStudents(BlackboardDbContext context)
        {
            var students = await context.Students.ToListAsync();

            await context.SaveChangesAsync();

            return(students);
        }
        //TODO: Add assignment
        public static async Task AddAssignment(Assignment assignment, BlackboardDbContext context)
        {
            if (!(await context.Courses.AnyAsync(a => a.Assignments.Contains(assignment))))
            {
                await context.Assignments.AddAsync(assignment);

                await context.SaveChangesAsync();
            }
        }
        public static async Task AddCourse(Course course, BlackboardDbContext context)
        {
            if (!(await context.Courses.AnyAsync(c => c.CourseName == course.CourseName)))
            {
                await context.Courses.AddAsync(course);

                await context.SaveChangesAsync();
            }
        }
        public static async Task AddStudent(Student student, BlackboardDbContext context)
        {
            if (!(await context.Students.AnyAsync(s => s.AUID == student.AUID)))
            {
                await context.Students.AddAsync(student);

                await context.SaveChangesAsync();
            }
        }
        public static async Task AddCourseStudent(CourseStudent courseStudent, BlackboardDbContext context)
        {
            if (!(await context.CourseStudents.AnyAsync(
                      cs => (cs.CourseName == courseStudent.CourseName) &&
                      (cs.StudentAUID == courseStudent.StudentAUID))))
            {
                await context.CourseStudents.AddAsync(courseStudent);

                await context.SaveChangesAsync();
            }
        }
        public static async Task <IEnumerable <Course> > GetCourses(BlackboardDbContext context)
        {
            if (await context.Courses.AnyAsync())
            {
                var courses = await context.Courses.ToListAsync();

                await context.SaveChangesAsync();

                return(courses);
            }
            return(null);
        }
Esempio n. 10
0
        public static async Task <IEnumerable <Assignment> > GetAssignments(BlackboardDbContext context)
        {
            if (await context.Assignments.AnyAsync())
            {
                var assignments = await context.Assignments.ToListAsync();

                await context.SaveChangesAsync();

                return(assignments);
            }
            return(null);
        }
Esempio n. 11
0
        public static async Task <IEnumerable <CourseStudent> > GetCourseStudentByStudentId(int auId, BlackboardDbContext context)
        {
            if (await context.CourseStudents.AnyAsync(cs => cs.StudentAUID == auId))
            {
                var courseStudents = await context.CourseStudents
                                     .Where(cs => cs.StudentAUID == auId)
                                     .ToListAsync();

                await context.SaveChangesAsync();

                return(courseStudents);
            }
            return(null);
        }
Esempio n. 12
0
        public static async Task <IEnumerable <CourseStudent> > GetCourseStudentByCourseName(string courseName, BlackboardDbContext context)
        {
            if (await context.CourseStudents.AnyAsync(cs => cs.CourseName == courseName))
            {
                var teacherCourses = await context.CourseStudents
                                     .Where(cs => cs.CourseName == courseName)
                                     .ToListAsync();

                await context.SaveChangesAsync();

                return(teacherCourses);
            }
            return(null);
        }
Esempio n. 13
0
        public static async Task <IEnumerable <TeacherCourse> > GetTeacherCoursesByCourseName(string courseName, BlackboardDbContext context)
        {
            if (await context.TeacherCourses.AnyAsync(tc => tc.CourseName == courseName))
            {
                var teacherCourses = await context.TeacherCourses
                                     .Where(tc => tc.CourseName == courseName)
                                     .ToListAsync();

                await context.SaveChangesAsync();

                return(teacherCourses);
            }
            return(null);
        }
Esempio n. 14
0
        public static async Task <IEnumerable <AssignmentStudent> > GetAssignmentByStudentId(int auId, BlackboardDbContext context)
        {
            if (await context.AssignmentStudents.AnyAsync(as_ => as_.StudentAUID == auId))
            {
                var assignmentStudents = await context.AssignmentStudents
                                         .Where(as_ => as_.StudentAUID == auId)
                                         .ToListAsync();

                await context.SaveChangesAsync();

                return(assignmentStudents);
            }
            return(null);
        }
Esempio n. 15
0
        public static async Task <IEnumerable <Assignment> > GetStudentAssignmentsByCourseIDAndStudentID(string courseName, int auId, BlackboardDbContext context)
        {
            var assignmentStudents = await context.AssignmentStudents
                                     .Where(as_ => as_.StudentAUID == auId)
                                     .Where(cn_ => cn_.Assignment.CourseName == courseName)
                                     .ToListAsync();

            await context.SaveChangesAsync();

            List <Assignment> matchingAssignment = new List <Assignment>();

            foreach (var entity in assignmentStudents)
            {
                matchingAssignment = await context.Assignments.
                                     Where(a => a.AssignmentId == entity.AssignmentId).
                                     ToListAsync();
            }
            return(matchingAssignment);
        }