0

I have the following tables:

  **Table Person**

    public long Id { get; set; }
    public int Number { get; set; }
    public string Name { get; set; }
    public string NameDesportivo { get; set; }
    public string Title { get; set; }
    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
    public DateTime Birthdate { get; set; }

    public Nullable<int> CC { get; set; }
    public Nullable<int> NIF { get; set; }
    public Nullable<bool> Active { get; set; }
    public string Natural { get; set; }
    public string Nacionality { get; set; }       
    public string fatherName { get; set; }
    public string motherName { get; set; }
    public string street { get; set; }
    public string numberDoor { get; set; }
    public string local { get; set; }
    public string parish { get; set; }        
    public int Id_Contacto { get; set; }          


    public virtual ICollection<Contact> Contact { get; set; }
    public HabLiterarias HabLiterarias { get; set; }


   **Table ContactPerson**

     public int ContactID
     public int PersonId

   **Table ContactType**

    public long ID { get; set; }
    public string Name { get; set; }
    public Nullable<bool> Active { get; set; }
    public string UserIDModification { get; set; }
    public Nullable<System.DateTime> DataModification { get; set; }

    public virtual ICollection<Contact> Contact { get; set; }

  **Table Contact**

    public long ID { get; set; }
    public Nullable<long> ContactTypeID { get; set; }
    public string ContactValue { get; set; }


    public virtual ContactType ContactType { get; set; }
    public virtual ICollection<Person> Person { get; set; }

What I'm trying to do is when I create an Person insert more than one contact of that person at the some time: For example Insert type contact mail and it´s value and contact type phone and it's value into the table contact. Those any one have any ideias. Thank you

Francisco
  • 5
  • 1
  • 7
  • Is there any one that can help me. Do I have to use javascript to do this? – Francisco Nov 20 '15 at 20:26
  • You do not need javascript if you have a fixed number of `Contact` - just initialize with collection with x number of `Contact` and use a `for` loop or `EditorTemplate` for typeof `Contact` to generate the html. But if you need to dynamically add (and remove) them, refer the answers [here](http://stackoverflow.com/questions/29161481/post-a-form-array-without-successful/29161796#29161796) and [here](http://stackoverflow.com/questions/28019793/submit-same-partial-view-called-multiple-times-data-to-controller/28081308#28081308) for some options –  Nov 22 '15 at 03:13

0 Answers0