Beispiel #1
0
        public async Task <JsonResult> GetAsync(string courseId)
        {
            DelftContext context = new DelftContext();

            var course = context.Courses.FirstOrDefault(i => i.CourseCode == courseId);

            var courseTags         = context.CourseToTag.Where(i => i.CourseCode == courseId);
            var course2Instructors = context.CourseToInstructor.Where(i => i.CourseCode == courseId);

            course.Tags = context.Tags.Where(i => courseTags.Any(j => j.TagName == i.TagName)).ToList();
            course.ResponsibleInstructor = course2Instructors.Where(i => !i.IsResposible).Select(i => new Instructor {
                Email = i.Email
            }).ToList();
            course.OtherInstructors = course2Instructors.Where(i => i.IsResposible).Select(i => new Instructor {
                Email = i.Email
            }).ToList();
            //course.Tags = context.Tags.ToList();


            //IEPCourse newC = (IEPCourse)course;
            //newC.CourseTags = newC.Tags.Select(i => i.TagName).ToList();
            //newC.ResponsibleInstructor = course2Instructors.Where(i => i.IsResposible).Select(i => context.Persons.FirstOrDefault(j => j.Email == i.Email)).ToList();
            //newC.OtherInstructors = course2Instructors.Where(i => !i.IsResposible).Select(i => context.Persons.FirstOrDefault(j => j.Email == i.Email)).ToList();
            return(Json(course));
        }
Beispiel #2
0
        public async Task <JsonResult> GetAsync()
        {
            DelftContext context = new DelftContext();

            foreach (var course in context.Courses)
            {
                course.Tags = context.CourseToTag.Where(i => i.CourseCode == course.CourseCode).Select(i => new Tag {
                    TagName = i.TagName
                }).ToList();
            }

            return(Json(context.Courses));
        }
        public async Task <JsonResult> GetAsync()
        {
            DelftContext context = new DelftContext();

            return(Json(context.Tags));
        }
        public async Task <JsonResult> GetAsync(string email)
        {
            DelftContext context = new DelftContext();

            return(Json(context.Persons.FirstOrDefault(i => i.Email == email)));
        }