我需要一些帮助,
我会简单的做。我有一个有很多约会的对象客户。就像是:
public partial class Client
{
...
public virtual IList<Appointment> Appointments{ get; set; }
}
有没有办法在 asp 中创建一个在同一页面中有约会的新客户?
PS:现在,我可以通过将客户 ID 传递给部分视图并使用 ajax 和部分视图来向现有客户添加约会。但是,新客户还没有 ID。我该怎么办?
更新:精度
这是我在编辑视图中的内容:
<p>
@Ajax.ActionLink("NewMeeting", "NewAppointmentFrm", new { clientId = Model.Id }, new AjaxOptions { UpdateTargetId = "appointmentPopup", OnSuccess = "displayFormInPopup('#appointmentPopup','" + "NewMeeting") + "',600,'auto');" })
</p>
<div style="display:none;width:600px" id="appointmentPopup"></div>
在控制器中我有
Appointment appointment = new Appointment()
{
Client = GetClientById(clientId)
};
return PartialView("NewAppointmentFrm", appointment);
通过提交 PartialView (NewAppointmentFrm - Appointments Details),我可以:
public ActionResult CreateClientAppointment(int clientId, Appointment appointment)
{
var client = GetClientById(clientId);
client.Appointments.add(appointment)
SaveClient(client);
return RedirectToAction("Edit", new { id = candidateId });
}
谢谢你的帮助