Reputation: 225
I want to add two instances of my model at the same time, that is the user will enter fill the same form in same page and he will send at the same time the two completed references to the database. Do you have some idea how can I achieve this ?
Thank you for your help!
Upvotes: 2
Views: 674
Reputation: 1879
Use View model with two properies of your model:
public class MyViewModel
{
public Model ModelA { get; set; }
public Model ModelB { get; set; }
}
Upvotes: 1
Reputation: 13765
One thing you could do (and I'm hoping I'm interpreting your question properly) is have a model set up as such:
public class Foo
{
public int Id { get; set; }
public string Something { get; set; }
}
public class Bar
{
public Foo Foo1 { get; set; }
public Foo Foo2 { get; set; }
}
In your view you would take in a model of Bar (which has contained within it two Foo objects)
Hopefully this helps, could potentially expand on this if specifics are added to your question.
Upvotes: 1