약간의 도움이 필요합니다.Asp MVC 4 : 새 부모에게 자식 추가
나는 간단하게 할 것입니다. 많은 약속이있는 개체 클라이언트가 있습니다. 비슷한 :
public partial class Client
{
...
public virtual IList<Appointment> Appointments{ get; set; }
}
같은 페이지에 약속이있는 새 클라이언트를 만드는 방법은 있습니까?
P.S : 지금은 클라이언트 ID를 partialview에 전달하고 ajax 및 partialView를 사용하여 기존 고객에게 약속을 추가 할 수 있습니다. 그러나 새로운 고객은 이드가 아닙니다. 내가 뭘해야 해?
UPDATE : 정밀도
이 내 편집보기로했습니다 것입니다 : 내가 가지고있는 CONTROLER에서
<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 - 약속 세부 정보), 다음과 같이합니다.public ActionResult CreateClientAppointment(int clientId, Appointment appointment)
{
var client = GetClientById(clientId);
client.Appointments.add(appointment)
SaveClient(client);
return RedirectToAction("Edit", new { id = candidateId });
}
당신의 도움에 감사드립니다.
이제 클라이언트를 편집하고 appoitment를 추가하려면 routesValues에 clientId를 전달하여 Ajax 팝업으로 열린 PartialView를 작성했습니다. 새 클라이언트에 대해 동일한 프로세스가 필요합니다. – user1845394
가장 쉬운 방법은 클라이언트보기를 클라이언트 데이터 편집으로 분할하고 약속 추가 + 기존 약속을 제거하는 옵션 추가 (테이블에있는 경우)입니다. – Boranas
하지만 무엇을할까요? 부분보기로 전달 하시겠습니까? 이제 편집보기에서 클라이언트 ID를 전달하고 약속 부분보기의 제출시 다음을 수행합니다. return RedirectToAction ("Edit", new {id = candidateId}); 새로운 객체로 무엇을 할 것인가? – user1845394