I'm porting my site, www.spelldamage.com, to the MVC framework. I've successfully gotten the master pages setup and ripped out all the runat="server" junk. At the basic level the site renders the same way it did before. I want to port it to the MVC framework for the RESTful architecture and the elegant URLs (and just thinking about routing has me drumming up knew ideas for the site).
Anyway, the MVC architecture is all about separating responsibilities in your apps. So let me throw this scenario out there (hopefully someone here is familiar with World of Warcraft a bit).
Let's say you play World of Warcraft, and you play a Mage class. My SpellDamage calculator is able to perform a lookup in the WoWArmory (an XML pull from the Blizzard website) to pull your character's information. I then store it in a database and perform spell damage calculations using the values pulled. The way it occurs now is obviously with post backs. You enter your character's name/realm into two text fields, and click the Get Data button (which fires the ArmoryPull_Click event). Inside the ArmoryPull_Click event I pull the data from the WoWArmory, store it in a DB, populate some text fields, and then fire the Calculate event. Inside the calculate event the values are pulled from the text fields and used in the calculations, then the results are displayed to the user. Here's a basic flowchart:
Visitor Enters Name/Realm => WoWArmory Pull => Store in DB & Fill in Text Fields => Fire Calculate Event => Display Results
Now, the results are essentially in two parts. The page showing the results also shows the Mage's information such as level, guild, battlegroup, etc... along with the actual spell damage results. Using the post back method, it's as simple as databinding some gridviews to show the spell damage results (and setting the text attribute on some literals). Using MVC, I'm a bit confused about which actions to write. I was read that MVC controllers generally should have 8 actions, and more than that should be very well thought out (the 8 are: Index, List, Show, Edit, New, Create, Update, and Delete; the last three don't have view associated with them).
Index was easy, it simple shows the default UI with no calculations or lookups occurring. I'm stuck on the Show action (I know, I'm not limited to those 8 actions, but want to try to stick with conventions). I was pleasantly surprised at how easy the lookup part flowed while coding the Show action. A simple url like www.spelldamage.com/Mage/Name/Realm/US will first check if the character is in the DB. If it is, pull the data from there. If not, pull from the WoWArmory.That part works flawlessly. Earlier I asked how to pass more than one object to the View, and your advice to combine them into a viewController class worked great.
However, as I'm working on this I'm wondering if I'm breaking the true meaning of an MVC framework. Do I perform all this work inside the Show action? Or should I be passing responsibility off to another action at some point? And, if I should be, what method would I use to move to the new action cleanly, RedirectToAction?
Sorry for the long post, hopefully it made enough sense... :)
Thanks in advance!
Did I answer your question(s)? Phweew...