Manipulate polygons

I'm making a web application for generate and store a polygon on a database. Folowing the documentation i can draw the polygon by passing the coordinates by code, but for this application i'll need to draw the polygon on the map and after save it on the database.

So i have 2 questions, the first is how can i draw a polygon just by clicking on the map (of course if it's possible to do), and the second is how can i get this polygon for save on the database.

For the second question, the problem is, i'm creating the polygon by code, editing the polygon on the map and trying to catch the edited polygon from the map componenet, but the polygon aways stay at the same way that i generated on the begining, and not the edited polygon, so the second question is this case, i'm trying to use the event OnPolyElementEditEnd but even if with the event, i'm not getting the edited polygon

Unfortunately there is no built-in functionality to draw polygons on the map. However you can use the OnMapClick event to catch coordinates and use those to draw a simple polygon. The polygons that are added to the map with AddPolygon can be accessed in the Polygons collection. You can save the list of coordinates in the Polygons collection to a database manually.

Please note that updated polygon coordinates are returned as JSON in the CustomData of the OnPolyElementEditEnd event.

This download contains sample code:
Sample

ok, i'll use this event to catch the changed polygon from now. Talking about what you sad of the OnMapClick event to catch the coordinates and generate the polygon, is there some sample that i can use to create this function?

Unfortunately there's currently no sample available for this scenario.
However this is a good suggestion and we'll consider adding this in a future version.

thank you for the help. For now, i'll use the component based on the documentation and wait for future versions.