Bring related data in a table

Asked

Viewed 27 times

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. inserir a descrição da imagem aqui

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);
    }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.