我有一个简单的asp.net core控制器模型:
[HttpPost]
public async Task<DefaultResponse> AddCourse([FromBody]CourseDto dto)
{
var response = await _courseService.AddCourse(dto);
return response;
}
我的模型是:
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 { get; set; }
}
我试图使用自定义模型绑定器或操作筛选器设置“OrganizationCode”的值,但没有成功。如果您能建议在执行操作之前更新模型的正确方法,我会非常感激。谢谢。