0

I am trying to display a json array which I got from consuming a web service that returns a list of resourceRequests that contain an attribute 'dateDepot' of type DateTime but it doesn't work unlike type Date it works fine

My entity :

public class ResourceRequestViewModel
{
    [Key]
    public int requestId { get; set; }

    [StringLength(255)]
    public string Director { get; set; }

    [StringLength(255)]
    public string EducationScolarity { get; set; }

    [StringLength(255)]
    public string Title { get; set; }

    public DateTime depotDate { get; set; }
 }

My view :

    @foreach (var item in ViewBag.result)
    {
        <tr>
            <td>
                @item.requestId
            </td>
            <td>
                @item.Director
            </td>
            <td>
                @item.depotDate
            </td>
        </tr>
    }

My controller :

public ActionResult Index()
{
        List<ResourceRequestViewModel> liste = new List<ResourceRequestViewModel>();
        HttpClient Client = new HttpClient();

        Client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
        HttpResponseMessage response = Client.GetAsync("http://localhost:18080/InfinityMAP-web/rest/ResourceRequestService/getResourceRequest").Result;

        if (response.IsSuccessStatusCode)
        {
           ViewBag.result= response.Content.ReadAsAsync<List<ResourceRequestViewModel>>().Result;
        }
        else
        {
           ViewBag.result ="ERRORRR";
        }

        return View();
}

My Json output from the web service :

[
{
    "requestId": 1,
    "client": {
        "id": 1,
        "nom": null,
        "ipAdress": null,
        "logo": null,
        "categorie": "client_prive",
        "typeClient": "nouveau_client",
        "etat": null
    },
    "listMandats": [],
    "director": "Fadi Ben nejma",
    "title": "Title1",
    "educationScolarity": "Uni",
    "depotDate": 1541026800000,
    "depotHour": 12,
    "mandateStartDate": "2018-10-30",
    "mandateEndDate": null,
    "requiremenets": "php angular html",
    "searchedProfile": "Backend Developper",
    "yearsOfExperience": 5,
    "EducationScolarity": "Uni",
    "project": {
        "id": 1,
        "statut": "projet_encours",
        "name": "slim",
        "nom": "aouadi",
        "etat": "1",
        "projetStartDate": "2018-10-01",
        "projetEndDate": "2018-10-31"
    },
    "Director": "Fadi Ben nejma"
}
]

The error I get is :

Error reading date. Unexpected token: Integer. Path '[0].depotDate'

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
AOUADI Slim
  • 299
  • 1
  • 8
  • 27

0 Answers0