我的asp.net核心控制器有一个简单的模型:
[HttpPost]
public async Task<DefaultResponse> AddCourse([FromBody]CourseDto dto)
{
var response = await _courseService.AddCourse(dto);
return response;
}
Run Code Online (Sandbox Code Playgroud)
我的模型是:
public class CourseDto
{
public int Id { get; set; }
public string Name { get; set; }
public string Genre { get; set; }
public string Duration { get; set; }
public string Level { get; set; }
public string AgeRange { get; set; }
public string Notes { get; set; }
public bool Active { get; set; }
public string OrganisationCode …Run Code Online (Sandbox Code Playgroud) model-binding custom-model-binder asp.net-core-mvc asp.net-core