Here's my model
public class TaskForUpdateDTO
{
[Required]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Name { get; set; }
}
and my controller
[HttpPut]
public ActionResult<List<TaskDTO>> Put([FromBody] List<TaskForUpdateDTO> tasks )
{
List<TaskBO> tasksForUpdate = TaskForUpdateDTO.MapToBOList(tasks);
tasksForUpdate = _serviceManager.TaskService.Update(tasksForUpdate);
if (tasksForUpdate is null) return NotFound();
return Ok(TaskDTO.MapToDTOList(tasksForUpdate));
}
and body of my request
[{
"Name":"Do Laundry",
"UserId":1
},
{
"Name":"Wash Dishes",
"UserId":1
}]
when sending a PUT request, I'm not getting a 400 error , which I should because I'm not sending the Id of the item.
how can I fix this?