0

How can I somehow pull the previous route ID to filter on my current page? I am going from a MediaDetails page to a GenreDetails page. The MediaDetails page sends me over to GenreDetails where I can list movies by genre. I would like to filter with C-linq to only have movies by genre for the given media that I cliked on.

So for instance

  1. I click DVD - which has an ID of 1

  2. I see all the Genres - which includes "Talk Show" for instance.

  3. I click "Talk-Show" and only Talks Shows of Media Type 1 appear.

Please let me know if I need to explain this a little better. I know it should be fairly straightforward, just don't know how to get it.

The razor code is below...I just need to figure out that PREVIOUSID part of the code.

    @foreach (var item in @Model.Movies.Where(x => x.MediaTypeID == **PREVIOUSID**))
    {
            <tr>
                <td class="col-sm-10">
                    @Html.DisplayFor(Model => item.MovieTitle)
                </td>
                <td class="col-sm-10">
                    @Html.DisplayFor(Model => item.MovieYear)
                </td>
            </tr>
    }

EDIT: And actually I suppose it may be slightly more challenging because I need the id from 2 routes ago since I follow this path:

Media ID (what I want)

Media Details -which lists Genres

Genre Details - which lists all the movies in that genre.

I am also using a version of ASP.Net Core which does not contain a definition for RequestContext.

Community
  • 1
  • 1
sqlcdr
  • 123
  • 2
  • 8
  • You can't get anything from the **previous** route if you not pass it in an explicit way. E.g. the user selects DVD and you add `?media=dvd` to the query string. Then they select *talk show* and you add `&genre=talkshow`. Then, upon any request you have every bit of the query in the query string. – Wiktor Zychla May 05 '19 at 17:36
  • @WiktorZychla Where would I update the query string? Would that be in the context files? – sqlcdr May 05 '19 at 17:41
  • You update the query string when the user clicks anything. You can do it both client side and server side. – Wiktor Zychla May 05 '19 at 17:42
  • @WiktorZychla Do you think this link will be helpful for my purposes? https://stackoverflow.com/questions/9771718/how-to-update-querystring-in-c – sqlcdr May 05 '19 at 17:45
  • Yes, if done server side. – Wiktor Zychla May 05 '19 at 17:48
  • @WiktorZychla, I am able to generate a new URL string now. But how do I generate a razor page and use the stored procedure with my new URL query? – sqlcdr May 26 '19 at 01:44

0 Answers0