The pull request with all the code.

this controller has quite a lot of persistence logic.  Perhaps look into placing this logic into models respective of the domain.