When I select a theater from a drop down and click on 'add a movie', this code is run.
public ActionResult Create(TheaterViewModel input)
{
var theater = new TheaterViewModel
{
TheaterId = input.TheaterId,
TheaterName = input.TheaterName,
MoviesForTheater = new List<Movie>
{
new Movie
{
Title = input.Movie.Title,
Category = input.Movie.Category
}
}
};
_repository.Add(theater);
_repository.Save();
return RedirectToAction("Index");
}
The resulting database entry is in Json format and is as below..
{
"TheaterId": 12312,
"TheaterName": "AMC",
"MoviesForTheater": [
{
"Title": "Shrek",
"Category": "G",
}
],
}
When I add a second movie to this theater following the same work flow.. that is, pick a theater and then add 2nd movie details, I want the second movie to be added next to first movie in the same document as follows and so on for additional movies in future...
{
"TheaterId": 12312,
"TheaterName": "AMC",
"MoviesForTheater": [
{
"Title": "Shrek",
"Category": "G",
},
{
"Title": "Shrek2",
"Category": "G",
}
],
}
How do I change my actionresult code to accomplish this feature..Thanks for your help..