When I've done this in the past, my strategy has been to keep an array of possible moves for each piece. So to see if the king is in check, you just loop through the opponent pieces, checking each of their possible moves. Probably want to calculate the king's moves after all the other pieces. So when checking whether the king can move to a space, if it's a possible move by an opposing piece, don't add it to the array.
There are other benefits to maintaining these arrays too, for showing in the UI, etc.