Introduced a BaseEntity for more easy access to all the properties.
Extracted a common function for insert and update to put all the stuff from the request into the entity.
Reformated the code.