Building a user input form that can take many objects (viewmodel contains lists of other objects) that can be added and deleted (those added will be displayed in a list coming from a partial page), but I don't want the objects to be sent to the database until the final submit where all objects will be sent to the database at once.
This is to stop unnecessary additions to the database if a user leaves the form after adding some objects.
What's the best way of achieving this? I was thinking storing the model in a session updated by the controller - is this advisable?
Example Model:
public class ViewModel
{
public string SchoolName {get;set;}
public List<Student> student {get;set;}
public List<Course> courses {get;set;}
}
public class Student
{
public string Name {get;set;}
}
public class Course
{
public string Code {get;set;}
}