public void DeleteCatalogueMentor(Mentor mentor, int schoolId, int catalogueId) { Domain.Catalogue catalogue = _context.Catalogues.Where(c => c.SchoolId == schoolId) .Include(c => c.MentorCatalogues).FirstOrDefault(c => c.Id == catalogueId); Domain.MentorCatalogue deleteCatalogueMentor = catalogue.MentorCatalogues .FirstOrDefault(mc => mc.MentorId == mentor.Id); catalogue.MentorCatalogues.Remove(deleteCatalogueMentor); _context.SaveChanges(); }
public Mentor AddCatalogueMentor(Mentor mentor, int schoolId, int catalogueId) { Domain.MentorCatalogue newCatalogueMentor = new Domain.MentorCatalogue() { MentorId = mentor.Id, CatalogueId = catalogueId }; Domain.Catalogue catalogue = _context.Catalogues.Where(c => c.SchoolId == schoolId) .FirstOrDefault(c => c.Id == catalogueId); catalogue.MentorCatalogues.Add(newCatalogueMentor); _context.SaveChanges(); return(mentor); }