title: How to handle datatypes posted from Angular to WebAPI?
body: <p>I am facing this problem where my API resource (View Model) has datatypes like <code>int</code> or <code>long</code>. In my Angular App I am using <code>reactive forms</code> and after it's initialization, all controls take <code>null</code> value.</p>
  
  <p>i.e.</p>
  
  <pre><code>this.patientRestrationForm = this.formBuilder.group({
        patientFileId: new FormControl(null),.......
  </code></pre>
  
  <p>and the JSON output is </p>
  
  <pre><code>{ "patientFileId": null}
  </code></pre>
  
  <p>in my API controller this <code>null</code> is recognized as a <code>string</code> and hence the model fails to pass the validation check,</p>
  
  <pre><code>if (!ModelState.IsValid) {
      return StatusCode (400, ModelState);
  };
  </code></pre>
  
  <p>This is a snapshot of the resource model,</p>
  
  <pre><code>public class SavePatientsRegistryResource {
          [Display (Name = "Patient File Id")]
          public long PatientFileId { get; set; }
  ......
  }
  </code></pre>
  
  <p>One more <strong>problem</strong> here is that the <code>ModelState</code> error is always empty for <code>datatypes</code> other than <code>string</code>.</p>
  
  <p>What am I missing here?, </p>
  
  <p>shall I use <code>string</code> <code>datatype</code> for all my properties in my resource model and <code>parse</code> downstream prior to saving data?</p>
  
  <p>Thank you.</p>