I used Angular and .net core 2 API. I built one reactive form in Angular and try to POST it to API side but here the problem is if I pass static value to server then it take properly but when I tried to pass form value to API then it got null. I don't understand what is the problem.
Here is my component code:
private executeClientCreation(clientFormValue) {
let client1 = {
"FirstName": "abc",
"LastName": "xyz",
"BusinessName": "ABC & Co.",
"ClientType": "Company",
"DateOfBirth": "1995-09-16",
"Status": "Active",
"CreatedDate": "2018-06-04",
"Createdby": 1
};
let client2: Client = clientFormValue;
console.log("client1", client1);
console.log("client2", client2);
let apiUrl = 'client';
this.repository.create(apiUrl, client1)
.subscribe(res => {
( < any > $('#successModal')).modal();
},
(error => {
this.errorHandler.handleError(error);
this.errorMessage = this.errorHandler.errorMessage;
})
)
}
typescript interface:
export interface Client {
ClientID: number;
FirstName: string;
MiddleName: string;
LastName: string;
DateOfBirth: Date;
Gender: string;
BusinessName: string;
ClientType: string;
PANNumber: string;
AadharNumber: number;
NameAsPerAadhar: string;
}
c# class:
[Table("clientmaster")]
public class Client : BaseClass, IEntity
{
public int Id { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string BusinessName { get; set; }
public string ClientType { get; set; }
public string Gender { get; set; }
public DateTime DateOfBirth { get; set; }
public string PANNumber { get; set; }
public long AadharNumber { get; set; }
public string NameAsPerAadhar { get; set; }
}


