Note that there are some explanatory texts on larger screens.

plurals
  1. POAsp Mvc 4 : Add Child to new Parent
    primarykey
    data
    text
    <p>I need some help,</p> <p>I'll do it simply. I have an object Client that has many Appointments. Something Like:</p> <pre><code>public partial class Client { ... public virtual IList&lt;Appointment&gt; Appointments{ get; set; } } </code></pre> <p>Is there a way in asp to create a new client with appointments in same page? </p> <p>P.S: For now, I can add appointments to an existing customer by passing to a partialview the Client id and using ajax and partialView. But, new clients haven't Id. What I've to do? </p> <p><strong>UPDATE : Precisions</strong></p> <p>This is what I've in my edit view:</p> <pre><code>&lt;p&gt; @Ajax.ActionLink("NewMeeting", "NewAppointmentFrm", new { clientId = Model.Id }, new AjaxOptions { UpdateTargetId = "appointmentPopup", OnSuccess = "displayFormInPopup('#appointmentPopup','" + "NewMeeting") + "',600,'auto');" }) &lt;/p&gt; &lt;div style="display:none;width:600px" id="appointmentPopup"&gt;&lt;/div&gt; </code></pre> <p>In the controler I have</p> <pre><code>Appointment appointment = new Appointment() { Client = GetClientById(clientId) }; return PartialView("NewAppointmentFrm", appointment); </code></pre> <p>And by submitted the PartialView (NewAppointmentFrm - Appointments Details), I do : </p> <pre><code>public ActionResult CreateClientAppointment(int clientId, Appointment appointment) { var client = GetClientById(clientId); client.Appointments.add(appointment) SaveClient(client); return RedirectToAction("Edit", new { id = candidateId }); } </code></pre> <p>Thanks for your help </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload