Max C. answered 06/12/19
PhD student who loves German, learning, and reading
Hello! Just like with other words, the ending can often provide hints as to the case being used. So, for example, wer is the nominative case for the word "who." Wen is accusative, and wem is dative.
One could say "Wer hat mir einen Kuss gegeben?" Which means "Who gave me a kiss?" You would not say the same sentence but replace wer with wen or wem, because the person doing the action is the "who" you are asking about.
It is useful to remember that the dative case is the indirect case, used in saying to/for whom something occurs, is given, etc. If you are giving the kiss to him, it is dative. There are situations where this might not be as straightforward, but I hope this is helpful.