Entropy and magnetocaloric effects in ferromagnets undergoing first- and second-order magnetic phase transitions