asp.net mvc - MVC Entity relationship - how to add child to entity as it's being created -


i have basinpeak entity default controller created in mvc project. when open http://xx.xx.xx.xx:51573/basinpeak/create , add new basinpeak, how can attach new note basinpeak @ time?

i want call create action notecontroller when new note created how pass noteid basinpeak?

or there easier way add note , have linked basinpeak

public class basinpeak {     public int id { get; set; }      public datetime datetime { get; set; }      public int edus { get; set; }      public int rating { get; set; }      public int? noteid { get; set; }      public virtual note note { get; set; } }     public class note {     public int id { get; set; }      public string notes { get; set; }      public datetime when { get; set; }      public string personid { get; set; }      public string history { get; set; } } 

you should ideally create basin peak first , create note attached basinpeak
if want user should not leave page basinpeak created try using ajax ideally should this.

you hit url basinpeak/create<br> form loaded create basin peak fill in values , hit submit send request using ajax (try using juery form ajax) if creation of basinpeak successfull return true id of created basinpeak. show him markup create form. because have id of created basinpeak can send request add note created basinpeak. 

still if want create in 1 go then. can try creating seperate view model. containing values of basinpeak created , values of note created. make view type view model , create peak , note accordingly


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -