コード例 #1
0
        public void DeleteCatalogueCourse(Course course, int schoolId, int catalogueId)
        {
            Domain.Catalogue catalogue = _context.Catalogues.Where(c => c.SchoolId == schoolId)
                                         .Include(c => c.CourseCatalogues).FirstOrDefault(c => c.Id == catalogueId);

            Domain.CourseCatalogue deleteCatalogueCourse = catalogue.CourseCatalogues
                                                           .FirstOrDefault(cc => cc.CourseId == course.Id);

            catalogue.CourseCatalogues.Remove(deleteCatalogueCourse);
            _context.SaveChanges();
        }
コード例 #2
0
        public Course AddCatalogueCourse(Course course, int schoolId, int catalogueId)
        {
            Domain.CourseCatalogue newCourseCatalogue = new Domain.CourseCatalogue()
            {
                CourseId    = course.Id,
                CatalogueId = catalogueId
            };

            Domain.Catalogue catalogue = _context.Catalogues.Where(c => c.SchoolId == schoolId)
                                         .FirstOrDefault(c => c.Id == catalogueId);

            catalogue.CourseCatalogues.Add(newCourseCatalogue);
            _context.SaveChanges();

            return(course);
        }