0

Basically, I have a C# MVC Web App, with Controllers that contain methods like this:

public ActionResult A (filters)

public ActionResult B (filters)

public ActionResult C (filters)

Each of these takes in filters, fills a list in the model using data (SQL from Stored Procedure), and generates a View (using DataTables). As far as the user sees, they click a button (A, B, C, etc.), select their desired filters, click "enter", and this process runs, generating the View (which is basically a report). The user can repeatedly go through this process, and each of these views/reports is generated above the other(s) on the page (they can scroll up and down). What I want to do, is have a different button --> filter page where they only select a "batch" of these reports they want generated. So if the user selects the option 'Batch 1', it generates Report A (with filters I define), then generates Report B (pre defined filters), then generates Report C (pre defined filters), ideally without any addition inputs from the user being needed.

Initially, I had been hoping to have some sort of "Super Controller", that would call ActionResult A, which would run through its process and generate the View. Then, instead of ending, it would return back to this "Super Controller" where it would then Call ActionResult B and run though the process, generating the view, etc. However, I'm now wondering if this is even possible in MVC. I do feel like something along the lines if this is the most "logical" solution, but it doesn't seem like Controller will let you implement something like this (at least in the ways I've tried). I've also tried to implement Tasks, but the only thing I was able to do with that was create 1 enormous view/report, which won't work for what I need (which is to generate lots of individual views, which each contain the ability to export to PDF, etc. via DataTables). If anyone could point me towards some sort of solution/ideas to do this it would be greatly appreciated. Please let me know if more info is needed.

Random
  • 1
  • 2
  • 1
    I'm not exactly sure what you are asking but the answer is either https://stackoverflow.com/questions/10915485/how-to-call-multiple-actions-in-view-in-asp-net-mvc or partial view (https://stackoverflow.com/questions/4210138/view-vs-partialview) – Alexei Levenkov Feb 04 '20 at 19:22
  • Hello, and welcome to Stack Overflow. In addition to the options proposed by @AlexeiLevenkov, it's likely useful to think about this as two separate questions: 1) How do you assemble a view model within a controller which shares the _logic_ for assembling reports, and 2) Within a view, how do you create elements which share the _presentation_ for displaying reports. That's likely to lead to a cleaner and simpler implementation that attempting to aggregate `ActionResults` themselves (which I believe is possible, but is going to be a lot more complicated). – Jeremy Caney Feb 04 '20 at 19:38

1 Answers1

0

You should see actions from controllers as entry points for your http requests. So, each request is mapped to one action, so this should not be possible, and you should not think of doing it this way.

It would be better to have on action that receives the data needed to be able to generate the uber report.

Bogdan Nedelcu
  • 78
  • 1
  • 1
  • 5