I have a model class named Parcel. This parcel includes Name, CenterPoint parameters:
public class Parcel
{
public string Name { get; set; }
public object CenterPoint { get; set; }
}
I am getting theese parameters from a map. When I click a parcel center point is calculated and setted in a variable in javascript. CenterPoint is a json object. Name is a plain text data.
I want to save CenterPoint as Json object in database. And when I get CenterPoint again on map, I can draw it.
When I post data to action method as following, my CenterPoint object is coming like this {object}.
Actually it should be like this: { type="point", x=121.32380004076, y=452.024614968}
[HttpPost]
public ActionResult SaveParcel(Parcel parcel)
{
return Json(new {parcel}, JsonRequestBehavior.AllowGet);
}
my javascript jode is here:
var postata = {
"Name": document.getElementById("name").value,
"CenterPoint": document.getElementById("center").value
};
$http({
method: 'POST',
url: "/Parcel/SaveParcel/",
data: postata,
}).success(function (data, status, headers, config) {
console.log(data);
});
How can I save and get JSON as orginally. Or is there is a good way passible?