У меня есть две модели, связанные со страницей бритвы,
Model Parent
Public Property ID as String
Public Property Notes as String
Public Property ChildModel as Child
Model Child
Public Property Email as String
Public Property Status as String
Моя структура внутренней таблицы выглядит примерно так:
ID | Notes
-------------------
1 | "test notes 1"
ParentID | Email | Status
-------------------------------------
1 | test1@gmail.com | Pending
1 | test2@gmail.com | Pending
1 | test3@gmail.com | Pending
Status
- это скрытое поле на таким образом, мой вопрос заключается в том, как эффективно связать Email
и Status
с моделью, чтобы у моего контроллера был доступ к обоим свойствам?
Один из возможных подходов, который я вижу, чтобы создать скрытое поле со значением EMail | Статус и l oop через контроллер для установки электронной почты и статуса. Тем не менее, это не звучит элегантно.
Редактировать: Пример кода
Public Class ConfigModel
Public Property Name as String
Public Property Users As List(Of UsersModel)
End Class
Public Class UserModel
Public Property Email() as String
Public Property Status() as String
End Class
Jquery
var Users = [];
Users.push({ 'Email': 'test1@gmail.com', 'Status': 'Pending' },
{ 'Email': 'test11@gmail.com', 'Status': 'Completed' }
);
obj.data.Users = JSON.stringify(Users);
$.ajax({
url: 'Controller/Submit'
type: 'POST',
data: data,
success: function (result) {
},
error: function (xhr, status, ex) {
}
});
Public Function Submit(model As ConfigModel) As ActionResult
//Unable to get the 'Users' array which is passed from jQuery
For Each email In model.Users
UsersList.Add(New Users With
{
.Email = email.Email,
.Status = email.Status
})
Next
End Function