public ActionResult <List <GroupStudents> > PutGroupStudents(int id, Stmtr std) { var toBeDeleted = _context.GroupStudents.Where(g => g.Gid == id && g.StId == std.RegNo).FirstOrDefault(); _context.GroupStudents.Remove(toBeDeleted); _context.SaveChanges(); return(_context.GroupStudents.Where(g => g.Gid == id).Include(s => s.St).ToList()); }
public async Task <ActionResult <Groups> > DeleteGroups(int id) { var toBeDeleted = _context.GroupStudents.Where(g => g.Gid == id); _context.GroupStudents.RemoveRange(toBeDeleted); _context.SaveChanges(); var groups = await _context.Groups.FindAsync(id); if (groups == null) { return(NotFound()); } _context.Groups.Remove(groups); await _context.SaveChangesAsync(); return(groups); }