Bring related data into a table

0

I need to bring the sessions of a particular movie, but if there is more than one session in the same cinema, bring only one die and the two schedules side by side. Anyone have any way to do it? It's my first application with Asp.Net and I'm a bit lost.

This is the method I did according to an example article from Microsoft, but it did not solve my problem, I looked into 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);
    }
    
asked by anonymous 16.05.2018 / 03:30

0 answers