PDA

View Full Version : Asp.Net MVC + Sencha Touch organization



BostonMerlin
30 Aug 2011, 7:12 AM
HI all, I'm organizing my projects folder structure and wanted to get a feel for how others have done the same when using asp.net MVC as your server side project solution. The mix between asp.net MVC controllers, models and view directories in addition to sencha touch controller, models and views directories can, on the surface, appear overly complex.

My project will grow fairly large over time so i want to make sure how i'm organizing the project makes sense and will be easy for others on our dev team to manage the project moving forward.

Currently, my solution contains asp.net MVC Areas.

Mobile.Tablet
+ Areas (asp.net resources)
++ Home
+++ Controllers
+++ Models
+++ Views
++ Finance
++ Alerts
+ Client (sencha resources)
++ App (app.js, namespaces.jss, routes.jss etc..)
+++ Areas
++++ Home
+++++ Controllers
+++++ Models
+++++ Views
++++ Finance
++++ Alerts
+ Content
+ Scripts

I toyed around with the idea of placing all sencha touch files into the same asp.net mvc (controller, model, view) directories to keep everything together. I just don't know what makes sense and since this is my first project i might find this to be unmanageable a year from now.

Thanks in advance,
John

Carlos F. Montano
31 Aug 2011, 6:34 AM
Hi BostonMerlin,

Ext JS 4.0 is new to most of us outside Sencha. It is really cool what they have done and we all are trying to get it right. Here's how I have arranged my solution projects:

ASP.NET MVC 3 App project

app

controller
model
view

extjs: all EXT JS

charts
resources
src
miscellaneous .js from Sencha

?views: normal ASP.NET MVC views for each page, meaning an index.cshtm file with 2 lines of code (although I am using razor), one to include EXT JS scripts, and another one to point to the main entry .js script
scripts: Here is where all the scripts .net adds to the mvc solution and I have added a few folders to arrange the scripts into maintenance, charts, etc.
The Controller is in a class library outside the ASP.NET MVC3 project. The solution includes these layers:

Controllers:

?controllers
JsonDto
ViewModels

Infrastucture
Model: Uses the EF and its data model edmx
Repository.EF
Services: use Request/Response
ServicesCache
UI.WPF: this one is used to play with stuff quickly but will not be deployed.
Many Windows services
ASP.NET MVC 3 Tests
I got this solution modeled after the case study on Scott Millet's book ASP.NET Design Patterns, recommend it highly!

Our solution is still in its infancy, so I cannot tell you what will happen in a year from now. I do know that to keep things loosely coupled, it will be best to have different layers...

Note: Watch out for those Datetime fields from C# to JSON when you serialize the collections, they will not work, you need to return a string from your controller and do the serialization to JSON there (as opposed to returning a JSONResult). This is needed to replace the /Date with "new date (thenumber in miliseconds here)"... take a look at the response to notice this. I use Google Chrome to see this (not IE). Firebug is good too.

Hope this helps and good luck!
Carlos F. Montano