【发布时间】:2018-01-04 11:34:02
【问题描述】:
它已经提出的问题。但我还是没有说清楚。 我必须在 reactjs 中调用 WEBAPI 的 POST 方法。但是我已经在 webapi 中创建了模型。所以我想知道如何将模型数据传递给 reactjs 中的 post call。
型号:
public class EmployeeModels
{
public int Id { get; set; }
public string name { get; set; }
public string mobile { get; set; }
public string email { get; set; }
public string dept { get; set; }
public string erole { get; set; }
}
我的 WEBAPI 发布方法:
//Insert new Employee
public IHttpActionResult CreateNewEmployee(EmployeeModels emp)
{
using (var ctx = new Employee())
{
ctx.tempemp.Add(new tempemp()
{
Id = emp.Id,
name = emp.name,
mobile = emp.mobile,
erole = emp.erole,
dept = emp.dept,
email = emp.email
});
ctx.SaveChanges();
}
return Ok();
}
现在我应该想从 reactjs 发布 Employeemodel。请提出任何建议。
【问题讨论】: