I'm developing a Web API using the ASP.NET Core 2 and I have a Model class as following.
public class Model
{
int id { get; set; }
DateTime date { get; set; }
}
I am using JSON in the Request Body. Request Json is like
{
"id" : 1,
"date" : 1525261719
}
Binding this JSON data to the Model class like this in Controller
[HttpPost]
public async Task<IActionResult> PostEvent([FromBody] Model model)
{
// Some code here
}
I was not able to parse Unix timestamp into the DateTime type. I saw some examples like JSON Converter, IModelBinder nothing helps. As I was new to .NET world I don't know how to proceed for this issue.
Any help is much appreciated.