I have created model in asp.net mvc with constructor to create new guid id for ID field which inherits from base class. Now i pass values for two parameters of the model other than ID from html page using angular js while calling the $http.post service. At web api I am receiving the null values only id is getting generated.
Model:
public class EngineeringTeamDTO : Entity
{
public EngineeringTeamDTO() : base()
{
}
public EngineeringTeamDTO(Guid ID) : base(ID)
{
}
[MaxLength(50)]
public String TeamName { get; set; }
public String Note { get; set; }
}
Web api
public IHttpActionResult PostEngineeringTeamDTO(EngineeringTeamDTODemo engineeringTeamDTO)
{
//code
}
So here in this web api I am getting null values for TeamName and Note parameter when calling the web api through the angular js. If i remove the constructor from model it works fine. But constructor is needful for me.
Angular Code:
$scope.addteam = function (ETD) {
debugger
$http.post($rootScope.addEngTeam, ETD).success(function (data) {
alert("ADDED")
}).error(function (data) {
$scope.Space = "Error" + data;
});
}
Html Code:
<input type="text" name="TeamName" ng-model="ETD1.TeamName" required />
<input type="text" name="Note" ng-model="ETD1.Note" required />
<input type="button" value="Add" ng-click="addteam(ETD1)"/>