i am creating mvc application using web api i am inserting the customer detail in database using ajax call(jquery) i am routing my call to
"LeadCustomer/SaveClient"
in my controller. on jquery side i debugged my code in chrome browser i am able to populate Data1 which is JSON STRING but on controller side DATA1 is null any help is appreciated.json string is not null i debugged it
What I have tried:
function insertInformation(name, telephone, email, Gender, birthday, cityid, stateid, Token, stageid, riskProfile, createdBy) {
debugger;
var Data1 = { CUSTOMER_NAME: name, MOBILE: telephone, EMAIL_ID: email, GENDER: Gender, DOB: birthday, CITY_ID: cityid, STATE_ID: stateid, TOKEN_ID: Token, STAGE_ID: stageid, CREATED_BY: createdBy, UPDATED_BY: Token };
alert(JSON.stringify(Data1));
$.ajax({
type: "POST",
url: apiUrl + "LeadCustomer/SaveClient",
data: JSON.stringify(Data1),
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
async: true,
headers: { "cache-control": "no-cache" },
success: function (obj) {
var result = obj;
alert(result);
},
error: function (obj) {
alert("error");
}
});
}
public class LeadCustomerEntity
{
public string GENDER { get; set; }
public string CUSTOMER_NAME { get; set; }
public int MOBILE { get; set; }
public string EMAIL_ID { get; set; }
public string DOB { get; set; }
public int STATE_ID { get; set; }
public int CITY_ID { get; set; }
public string CREATED_BY { get; set; }
public string UPDATED_BY { get; set; }
public string TOKEN_ID { get; set; }
public string STAGE_ID { get; set; }
}
[HttpPost]
[Route("LeadCustomer/SaveClient", Name = "SaveClient")]
public IHttpActionResult SaveClient([FromBody] LeadCustomerEntity Data1)
{
try
{
LeadCustomerMosl item = LeadCustomerRepository.LeadCustomerRegistration(Data1);
return Ok(item);
}
catch (Exception ex)
{
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
return Ok("Failed");
}
}