0
I need to bring the sessions of a certain film, but in case there is more than one session in the same cinema, bring only one data and the two times side by side. Does anyone have any way? It’s my first application with Asp.Net and I’m a little lost.
This is the method I did according to a microsoft example article, but it did not solve my problem, I searched on Viewmodels and could not find anything like what I needed
// GET: Filme
public ActionResult Index(int? id, int? sessaoID)
{
var viewModel = new FilmesIndex();
viewModel.Filmes = db.Filmes
.Include(i => i.Cinemas)
.Include(i => i.Sessoes)
.OrderBy(i => i.Nome);
if(id != null)
{
ViewBag.SessaoID = id.Value;
viewModel.Sessoes = viewModel.Filmes.Where(
i => i.FilmeID == id.Value).Single().Sessoes;
}
if(sessaoID != null)
{
ViewBag.SessaoID = sessaoID.Value;
viewModel.Sessoes = viewModel.Cinemas.Where(
x => x.CinemaID == sessaoID).FirstOrDefault().Sessoes;
}
return View(viewModel);
}
Welcome to SO-PT, don’t forget to do the [tour] and understand how the site works. Ideally you add a example of code that reproduces what is happening or what you have tried to do. See also Help Center How to Ask.
– Barbetta
I edited and placed my controller’s Index method.
– Nexus