Record is successfully inserted but 204 status code return in ASP.net Web API.
public class Customer
{
public int CustID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public string Company { get; set; }
public bool Isactive{ get; set; }
}
Isactive bit data type in database
public interface ICustomerRepository
{
Task<List> GetCustomers();
Task GetCustomerByID(int id);
Task ADDEditCustomer(Customer customer);
Task DeleteCustomer(int id);
}
public async Task ADDEditCustomer(Customer customer)
{
try
{
using (IDbConnection con = connection)
{
string sQuery = "USP_Customer";
int isactive;
con.Open();
DynamicParameters param = new DynamicParameters();
param.Add("@ACTION", "E");
param.Add("@CUSTID", customer.CustID);
param.Add("@NAME", customer.Name);
param.Add("@AGE", customer.Age);
param.Add("@COMPANY", customer.Company);
param.Add("@ISACTIVE", customer.isactive);
var result = await con.QueryAsync(sQuery, param, commandType: CommandType.StoredProcedure);
return result.FirstOrDefault();
}
}
catch (Exception ex)
{
throw ex;
}
}
[HttpPost]
public async Task<ActionResult> ADDEditCustomer([FromBody]Customer customer)
{
if (customer == null || !ModelState.IsValid)
{
return BadRequest("Invalid State");
}
return await _customerRep.ADDEditCustomer(customer);
}
It will return status code 204 in postman
I don't know how to handle in model
In my json file I will pass for post request
{
"CustID" : 0,
"Name" : "manish",
"Age": 23,
"Company": "Abc"
"Isactive": true
}