-
Notifications
You must be signed in to change notification settings - Fork 0
/
atom.xml
5891 lines (5374 loc) · 525 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Cramer on Code]]></title>
<link href="http://steventcramer.github.io//atom.xml" rel="self"/>
<link href="http://steventcramer.github.io//"/>
<updated>2015-09-15T20:51:05-04:00</updated>
<id>http://steventcramer.github.io//</id>
<author>
<name><![CDATA[Steven T. Cramer]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Plastic SCM vs Git Rebase]]></title>
<link href="http://steventcramer.github.io//blog/2015/08/26/plastic-scm-vs-git-rebase/"/>
<updated>2015-08-26T21:18:26-04:00</updated>
<id>http://steventcramer.github.io//blog/2015/08/26/plastic-scm-vs-git-rebase</id>
<content type="html"><![CDATA[<p><a href="https://github.com/ryanlanciaux">Ryan Lanciaux</a> and I were having a conversation about git rebase and I thought I would share the gist of it here.</p>
<p>Using <a href="https://plasticscm.com">Plastic SCM</a> I created the scenario Ryan was explaining. The beauty of Plastic SCM is how few words I need for you to understand the scenario we were discussing</p>
<h2>The Rebase Condition</h2>
<p><img src="http://steventcramer.github.io//assets/pictures/plastic-rebase/RebaseCondition.png" alt="Rebase Condition"></p>
<!-- more -->
<p>For more infomration on git rebase see Atlassian <a href="https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase">page</a>.</p>
<p>I have been using Plastic SCM for years now as my primary version control system. They have also implemented the git protocol and thus it works great with github, Visual Studio Online and bitbucket. Or any of the cloud providers that support git repositories. I highly recommend it.</p>
<p>Plastic does NOT do a rebase. Each changeset is considered immutable. And thus you can NOT change History! Think of all the mistakes we could rewrite in life if we could change history! Not to mention our code :).</p>
<p>You have two options.</p>
<h1>Reintegrate main then merge</h1>
<p>Merge main branch down to your feature branch then merge your feature back into the main. If you are doing conflict free pull requests this would be the best choice.</p>
<h2>Pending Reintegration of main branch in FeatureY</h2>
<p><img src="http://steventcramer.github.io//assets/pictures/plastic-rebase/PendingReintegration.png" alt="Rebase Condition"></p>
<h2>main branch Reintegrated into Feature Y</h2>
<p><img src="http://steventcramer.github.io//assets/pictures/plastic-rebase/Reintegrated.png" alt="Rebase Condition"></p>
<h2>Feature Y Merged into main</h2>
<p><img src="http://steventcramer.github.io//assets/pictures/plastic-rebase/FeatureYMerged.png" alt="Rebase Condition"></p>
<h1>Direct Merge</h1>
<p>Or Simply directly merge to the main branch.</p>
<p><img src="http://steventcramer.github.io//assets/pictures/plastic-rebase/DirectMerge.png" alt="Rebase Condition"></p>
<p>some of the reasoning for the rebase is to "clean up the history". My first though was... "you mean lie about history". </p>
<p>Using Plastic SCM and it's awesome GUI (yes it all can be done via command line) Isn't the <strong>actual</strong> history pretty easy to understand?</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Building MVC Jimmy Style]]></title>
<link href="http://steventcramer.github.io//blog/2015/08/23/jimmy-mvc/"/>
<updated>2015-08-23T13:13:37-04:00</updated>
<id>http://steventcramer.github.io//blog/2015/08/23/jimmy-mvc</id>
<content type="html"><![CDATA[<p>This blog is a step by step tutorial that transforms a default MVC 5 application into <a href="https://lostechies.com/jimmybogard/">Jimmy Bogard's</a> Feature oriented configuration as described in his <a href="https://lostechies.com/jimmybogard/2015/07/02/ndc-talk-on-solid-in-slices-not-layers-video-online/">presentation</a>. His sample project located <a href="https://github.com/jbogard/ContosoUniversity" title="here">here</a> was used to guide the way. The VSIX package and source code of this presentation are available <a href="http://steventcramer.github.io//assets/pictures/jimmy-mvc/JimmyMvcVsixProject.vsix">here</a>.</p>
<!-- more -->
<h1>Background</h1>
<h2>Layers to Features</h2>
<p><strong>From:</strong>
<img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/Layers.png" alt="NewProject"></p>
<p><strong>To:</strong>
<img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/Features.png" alt="NewProject"></p>
<h2>What is a feature</h2>
<p>A feature is a small vertical slice of a web site. The <strong>M</strong>odel, <strong>V</strong>iew and <strong>C</strong>ontroller of a <strong>single url</strong>. It can contain the following:
- Query
- QueryValidater
- QueryHandler
- Result
- Command
- CommandValidater
- CommandHandler
- UiController
- MappingProfile
- View </p>
<p>A Feature handles the <code>get</code> and or <code>post</code> of an http requests for a single url.<br>
Examples: <code>http://localhost/User/Index</code>, <code>http://localhost/User/Create</code>
It can be synchronous or asynchronous, and can have a redirect to url/Feature upon command success. Features use the <strong>CQRS light</strong> design pattern.</p>
<h2>CQRS Light</h2>
<p>The CQRS (Command Query Responsibility Segregation) pattern means many different thing to different people. The full blown CQRS with dual domain models and event sourcing etc. gets a bit overwhelming rather quickly. "<a href="https://lostechies.com/jimmybogard/2015/05/05/cqrs-with-mediatr-and-automapper/">CQRS Light</a>" is just the splitting of Features into Queries and Commands. A single domain model is the starting point and will not be split unless circumstances drive the need, which is unlikely. There is no event sourcing and most messaging is done in process using MediatR.</p>
<p>The Http protocol correlates rather well with CQRS Light.</p>
<p>Get = Read = Query
Post = Write = Command</p>
<p>The MediatR Nuget package will be used to implement CQRS light.</p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/MediatR.png" alt="MediatR"></p>
<p>This should all become clear as we implement. Let's get started.</p>
<h1>Tutorial</h1>
<h2>Create Default MVC 5 Application</h2>
<p>Create New Project named JimmyMvc</p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/NewProject.png" alt="NewProject"></p>
<p>Choose <code>MVC</code> and Press <code>Change Authentication</code> and select "No Authentication" </p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/SelectTemplate.png" alt="NewProject"></p>
<p>Deselect <code>Host in the cloud</code></p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/NoAuthentication.png" alt="NewProject"></p>
<p>Select Ok to create the project.</p>
<p>Run the app to confirm it works as is.</p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/ScreenShot.png" alt="NewProject"></p>
<p>Select <em>Tools->NuGet Package Manager->Package Manager Console</em> and enter: </p>
<p><code>Update-Package</code></p>
<p>Alternatively Select <em>Tools->NuGet Package Manager->Manage NuGet Packages for Solution</em></p>
<p>Upgrade all to the latest stable version.</p>
<p>Run the app to confirm it still works.</p>
<h2>Configure JustCode/ReSharper/CodeRush</h2>
<p>These tools are not required but they sure are handy. Take some time to configure them and they will help make your code cleaner and more consistent. This will not be covered here.</p>
<h2>Rename Views to Features</h2>
<p>Rename the <code>Views</code> folder to <code>Features</code></p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/FeatureFolder.png" alt="NewProject"></p>
<p>So now if you run the app you will get an error:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>
</span><span class='line'>The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
</span><span class='line'>~/Views/Home/Index.aspx
</span><span class='line'>~/Views/Home/Index.ascx
</span><span class='line'>~/Views/Shared/Index.aspx
</span><span class='line'>~/Views/Shared/Index.ascx
</span><span class='line'>~/Views/Home/Index.cshtml
</span><span class='line'>~/Views/Home/Index.vbhtml
</span><span class='line'>~/Views/Shared/Index.cshtml
</span><span class='line'>~/Views/Shared/Index.vbhtml
</span></code></pre></td></tr></table></div></figure>
<p>To fix this we change the view engine to one that looks in the proper location:</p>
<p>Create a new root folder named <code>Infrastructure</code>
<img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/InfrastructureFolder.png" alt="NewProject"></p>
<p>Inside the Infrastructure folder Create new class named: <code>FeatureRazorViewEngine</code> </p>
<p>Implement as follows:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Infrastructure</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">FeatureRazorViewEngine</span> <span class="p">:</span> <span class="n">RazorViewEngine</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">public</span> <span class="nf">FeatureRazorViewEngine</span><span class="p">()</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">ViewLocationFormats</span> <span class="p">=</span> <span class="k">new</span><span class="p">[]</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="s">"~/Features/{1}/{0}.cshtml"</span><span class="p">,</span>
</span><span class='line'> <span class="s">"~/Features/{1}/{0}.vbhtml"</span><span class="p">,</span>
</span><span class='line'> <span class="s">"~/Features/Shared/{0}.cshtml"</span><span class="p">,</span>
</span><span class='line'> <span class="s">"~/Features/Shared/{0}.vbhtml"</span><span class="p">,</span>
</span><span class='line'> <span class="p">};</span>
</span><span class='line'>
</span><span class='line'> <span class="n">MasterLocationFormats</span> <span class="p">=</span> <span class="n">ViewLocationFormats</span><span class="p">;</span>
</span><span class='line'> <span class="n">PartialViewLocationFormats</span> <span class="p">=</span> <span class="n">ViewLocationFormats</span><span class="p">;</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>To use the new ViewEngine, update the <code>Global.asax.cs</code> as follows:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">Infrastructure</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Optimization</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Routing</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">MvcApplication</span> <span class="p">:</span> <span class="n">System</span><span class="p">.</span><span class="n">Web</span><span class="p">.</span><span class="n">HttpApplication</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">protected</span> <span class="k">void</span> <span class="nf">Application_Start</span><span class="p">()</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">AreaRegistration</span><span class="p">.</span><span class="n">RegisterAllAreas</span><span class="p">();</span>
</span><span class='line'> <span class="n">FilterConfig</span><span class="p">.</span><span class="n">RegisterGlobalFilters</span><span class="p">(</span><span class="n">GlobalFilters</span><span class="p">.</span><span class="n">Filters</span><span class="p">);</span>
</span><span class='line'> <span class="n">RouteConfig</span><span class="p">.</span><span class="n">RegisterRoutes</span><span class="p">(</span><span class="n">RouteTable</span><span class="p">.</span><span class="n">Routes</span><span class="p">);</span>
</span><span class='line'> <span class="n">BundleConfig</span><span class="p">.</span><span class="n">RegisterBundles</span><span class="p">(</span><span class="n">BundleTable</span><span class="p">.</span><span class="n">Bundles</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// Replace Default ViewEngine with Feature version</span>
</span><span class='line'> <span class="n">ViewEngines</span><span class="p">.</span><span class="n">Engines</span><span class="p">.</span><span class="n">Clear</span><span class="p">();</span>
</span><span class='line'> <span class="n">ViewEngines</span><span class="p">.</span><span class="n">Engines</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="k">new</span> <span class="n">FeatureRazorViewEngine</span><span class="p">());</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>Running the application now should give you :</p>
<div class="highlight"><pre><code class="language-text" data-lang="text">The layout page "~/Views/Shared/_Layout.cshtml" could not be found at the following path: "~/Views/Shared/_Layout.cshtml".
</code></pre></div>
<p>To fix this, Update the <code>_ViewStart.cshtml</code> to point to the Feature based site Layout location.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="err">@</span><span class="p">{</span>
</span><span class='line'> <span class="n">Layout</span> <span class="p">=</span> <span class="s">"~/Features/Shared/_Layout.cshtml"</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>You application will now function using the "Feature" folder instead of the "View" folder.</p>
<h2>Removing the Controllers Folder</h2>
<p>Move <code>HomeController.cs</code> to the <code>Features\Home</code> directory and delete the Controllers folder.</p>
<p>Using the feature concept we no longer have to indicate the purpose of the controller by calling it <<em>Home</em>>Controller. Given it is in the <em>Home</em> namespace the prefix becomes redundant.</p>
<p>Rename <code>HomeController.cs</code> to <code>UiController.cs</code> and the class name to <code>UiController</code></p>
<p>Update the namespace inside the file.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Features.Home</span>
</span></code></pre></td></tr></table></div></figure>
<p>Running the application will now give an error:</p>
<div class="highlight"><pre><code class="language-text" data-lang="text">The resource cannot be found.
</code></pre></div>
<p>The url format is set in the <code>RouteConfig</code> as follows: (<em>Notice this is the default and is not changed.</em>)</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="n">routes</span><span class="p">.</span><span class="n">MapRoute</span><span class="p">(</span>
</span><span class='line'> <span class="n">name</span><span class="p">:</span> <span class="s">"Default"</span><span class="p">,</span>
</span><span class='line'> <span class="n">url</span><span class="p">:</span> <span class="s">"{controller}/{action}/{id}"</span><span class="p">,</span>
</span><span class='line'> <span class="n">defaults</span><span class="p">:</span> <span class="k">new</span> <span class="p">{</span> <span class="n">controller</span> <span class="p">=</span> <span class="s">"Home"</span><span class="p">,</span> <span class="n">action</span> <span class="p">=</span> <span class="s">"Index"</span><span class="p">,</span> <span class="n">id</span> <span class="p">=</span> <span class="n">UrlParameter</span><span class="p">.</span><span class="n">Optional</span> <span class="p">});</span>
</span></code></pre></td></tr></table></div></figure>
<p>MVC controllers are created using the <code>DefaultControllerFactory.CreateController</code> and it uses a naming convention of <code><controllerName>Controller</code> to get the controller type. This will no longer work with our new feature based naming convention.</p>
<p>To fix this create your own controller factory class in the <code>Infrastructure</code> Folder as follows:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Infrastructure</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Routing</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">ControllerFactory</span> <span class="p">:</span> <span class="n">DefaultControllerFactory</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">protected</span> <span class="k">override</span> <span class="n">Type</span> <span class="nf">GetControllerType</span><span class="p">(</span><span class="n">RequestContext</span> <span class="n">aRequestContext</span><span class="p">,</span> <span class="kt">string</span> <span class="n">aControllerName</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="kt">string</span> <span class="n">action</span> <span class="p">=</span> <span class="n">aRequestContext</span><span class="p">.</span><span class="n">RouteData</span><span class="p">.</span><span class="n">GetRequiredString</span><span class="p">(</span><span class="n">valueName</span><span class="p">:</span> <span class="s">"action"</span><span class="p">);</span>
</span><span class='line'> <span class="kt">string</span> <span class="n">typeName</span> <span class="p">=</span> <span class="s">"JimmyMvc.Features."</span> <span class="p">+</span> <span class="n">aControllerName</span> <span class="p">+</span> <span class="s">".UiController"</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="n">System</span><span class="p">.</span><span class="n">Reflection</span><span class="p">.</span><span class="n">Assembly</span> <span class="n">assembly</span> <span class="p">=</span> <span class="k">typeof</span><span class="p">(</span><span class="n">ControllerFactory</span><span class="p">).</span><span class="n">Assembly</span><span class="p">;</span>
</span><span class='line'> <span class="n">Type</span> <span class="n">type</span> <span class="p">=</span> <span class="n">assembly</span><span class="p">.</span><span class="n">GetType</span><span class="p">(</span><span class="n">typeName</span><span class="p">);</span>
</span><span class='line'> <span class="k">return</span> <span class="n">type</span><span class="p">;</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>To use this controller factory set it directly in the <code>Global.asax.cs</code> file using:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="n">ControllerBuilder</span><span class="p">.</span><span class="n">Current</span><span class="p">.</span><span class="n">SetControllerFactory</span><span class="p">(</span><span class="k">new</span> <span class="n">JimmyMvc</span><span class="p">.</span><span class="n">Infrastructure</span><span class="p">.</span><span class="n">ControllerFactory</span><span class="p">());</span>
</span></code></pre></td></tr></table></div></figure>
<p>Later after we add an IoC container this will need to be removed.</p>
<p>At this point the <code>Global.asax.cs</code> file should be as follows:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">Infrastructure</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Optimization</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Routing</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">MvcApplication</span> <span class="p">:</span> <span class="n">System</span><span class="p">.</span><span class="n">Web</span><span class="p">.</span><span class="n">HttpApplication</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">protected</span> <span class="k">void</span> <span class="nf">Application_Start</span><span class="p">()</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">AreaRegistration</span><span class="p">.</span><span class="n">RegisterAllAreas</span><span class="p">();</span>
</span><span class='line'> <span class="n">FilterConfig</span><span class="p">.</span><span class="n">RegisterGlobalFilters</span><span class="p">(</span><span class="n">GlobalFilters</span><span class="p">.</span><span class="n">Filters</span><span class="p">);</span>
</span><span class='line'> <span class="n">RouteConfig</span><span class="p">.</span><span class="n">RegisterRoutes</span><span class="p">(</span><span class="n">RouteTable</span><span class="p">.</span><span class="n">Routes</span><span class="p">);</span>
</span><span class='line'> <span class="n">BundleConfig</span><span class="p">.</span><span class="n">RegisterBundles</span><span class="p">(</span><span class="n">BundleTable</span><span class="p">.</span><span class="n">Bundles</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// Replace Default ViewEngine with Feature version</span>
</span><span class='line'> <span class="n">ViewEngines</span><span class="p">.</span><span class="n">Engines</span><span class="p">.</span><span class="n">Clear</span><span class="p">();</span>
</span><span class='line'> <span class="n">ViewEngines</span><span class="p">.</span><span class="n">Engines</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="k">new</span> <span class="n">FeatureRazorViewEngine</span><span class="p">());</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">//Replace Default Controller factor with Feature version</span>
</span><span class='line'> <span class="n">ControllerBuilder</span><span class="p">.</span><span class="n">Current</span><span class="p">.</span><span class="n">SetControllerFactory</span><span class="p">(</span><span class="k">new</span> <span class="n">JimmyMvc</span><span class="p">.</span><span class="n">Infrastructure</span><span class="p">.</span><span class="n">ControllerFactory</span><span class="p">());</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>The Application should now run. But what is the purpose of this application?</p>
<h2>The Business Case</h2>
<p>A Company wants to automate their purchase order (PO) approval process. To reduce clutter and wasted time, they want to establish a hierarchy for approval. People in the first group must approve before requesting action from the second. All of the people in the list must approve the PO in order for the funds to be allocated and the PO be issued as approved.</p>
<p>Typically the team that is closest to the project, needs to approve first. If all of them approve then the next group will be notified and requested to approve or reject. This second group is often a set of managers involved in a project. Finally the next group, potentially senior executives are involved. Lastly one person must have the financial signing authority to release the funds.</p>
<p>This blog only covers the implementation of "Approval List <strong>Templates</strong>" which can be reused when the user actually wants to request approval of a purchase order. The process of requesting approval of the purchase order is another business component and is not covered in this post.</p>
<p>Sample "Approval List Template" names are ... "Minimal Approval", "Medium Approval", "The Big Dogs"</p>
<h3>Class Diagram</h3>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/Main.png" alt="Model"></p>
<p>Granted this model is pretty simple in that the behavior is just CRUD. The use of the ApprovalListTemplate will have more domain behavior and possibly could be the topic of a future blog.</p>
<h3>Use Case</h3>
<p>Let's get started with our first use case. </p>
<p>As an administrator we need to be able to maintain a set of users for the application. </p>
<p>TODO Use case Diagram here</p>
<p>Being able to persist users will require a database. For this case we will use Entity Framework on top of SQL Server.</p>
<h3>Add Entity Framework 6</h3>
<p>Create a root folder named <code>Entities</code> and select it.
<img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/EntitiesFolder.png" alt="Model"></p>
<p>Press Ctrl-Shift-A To add a new item.</p>
<p>Select Visual C#->Data-> ADO.NET Entity Data Model And Name it "Model" </p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/AddEntity.png" alt="Model"></p>
<p>Select Empty Code First model and then Finish</p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/EmptyCodeFirst.png" alt="Model"></p>
<p>This will add the Entity Framework Nuget package to your project and Create a <code>Model.cs</code> file and update your <code>Web.config</code></p>
<p>Make sure the Entity Framework Nuget is up to date using Nuget Package Manager.</p>
<h3>DelegateDecompiler.EntityFramework</h3>
<p>Install <a href="https://www.nuget.org/packages/DelegateDecompiler.EntityFramework/0.16.0" title="Nuget">Nuget DelegateDecompiler.EntityFramework</a> See the <a href="https://github.com/hazzik/DelegateDecompiler" title="Delegate Decompile">github</a> page.
<img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/DelegateDecompilerNuget.png" alt="Model"></p>
<p>This will give you the <code>Computed</code> attribute and improved linq operations with it.</p>
<h2>User</h2>
<p>Now add a new class in the Entities folder named User.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Entities</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.ComponentModel.DataAnnotations</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">DelegateDecompiler</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">User</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">public</span> <span class="kt">int</span> <span class="n">UserId</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="kt">string</span> <span class="n">LastName</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="na"> [Display(Name = "First Name")]</span>
</span><span class='line'> <span class="k">public</span> <span class="kt">string</span> <span class="n">FirstAndMiddleName</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="na"> [Computed]</span>
</span><span class='line'> <span class="k">public</span> <span class="kt">string</span> <span class="n">FullName</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">get</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">return</span> <span class="n">LastName</span> <span class="p">+</span> <span class="s">", "</span> <span class="p">+</span> <span class="n">FirstAndMiddleName</span><span class="p">;</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>Compile. To Ensure the application builds.</p>
<p>Update <code>Model.cs</code> to add the DbSet for the User class and to not pluralize the table names:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Entities</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Data.Entity</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Data.Entity.ModelConfiguration.Conventions</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Linq</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">Model</span> <span class="p">:</span> <span class="n">DbContext</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="c1">// Your context has been configured to use a 'Model' connection string from your application's </span>
</span><span class='line'> <span class="c1">// configuration file (App.config or Web.config). By default, this connection string targets the </span>
</span><span class='line'> <span class="c1">// 'JimmyMvc.Model' database on your LocalDb instance. </span>
</span><span class='line'> <span class="c1">// </span>
</span><span class='line'> <span class="c1">// If you wish to target a different database and/or database provider, modify the 'Model' </span>
</span><span class='line'> <span class="c1">// connection string in the application configuration file.</span>
</span><span class='line'> <span class="k">public</span> <span class="nf">Model</span><span class="p">()</span>
</span><span class='line'> <span class="p">:</span> <span class="k">base</span><span class="p">(</span><span class="n">nameOrConnectionString</span><span class="p">:</span> <span class="s">"name=Model"</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// Add a DbSet for each entity type that you want to include in your model. For more information </span>
</span><span class='line'> <span class="c1">// on configuring and using a Code First model, see http://go.microsoft.com/fwlink/?LinkId=390109.</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// public virtual DbSet<MyEntity> MyEntities { get; set; }</span>
</span><span class='line'> <span class="k">public</span> <span class="k">virtual</span> <span class="n">DbSet</span><span class="p"><</span><span class="n">User</span><span class="p">></span> <span class="n">Users</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">protected</span> <span class="k">override</span> <span class="k">void</span> <span class="nf">OnModelCreating</span><span class="p">(</span><span class="n">DbModelBuilder</span> <span class="n">aDbModelBuilder</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">aDbModelBuilder</span><span class="p">.</span><span class="n">Conventions</span><span class="p">.</span><span class="n">Remove</span><span class="p"><</span><span class="n">PluralizingTableNameConvention</span><span class="p">>();</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<h2>Create Database Initializer</h2>
<p>Add a new class named <code>ModelInitializer</code> to the <code>Entities</code> Folder as follows:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Entities</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Collections.Generic</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">ModelInitializer</span> <span class="p">:</span> <span class="n">System</span><span class="p">.</span><span class="n">Data</span><span class="p">.</span><span class="n">Entity</span><span class="p">.</span><span class="n">DropCreateDatabaseIfModelChanges</span><span class="p"><</span><span class="n">Model</span><span class="p">></span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">protected</span> <span class="k">override</span> <span class="k">void</span> <span class="nf">Seed</span><span class="p">(</span><span class="n">Model</span> <span class="n">aModel</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">base</span><span class="p">.</span><span class="n">Seed</span><span class="p">(</span><span class="n">aModel</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'> <span class="kt">var</span> <span class="n">users</span> <span class="p">=</span> <span class="k">new</span> <span class="n">List</span><span class="p"><</span><span class="n">User</span><span class="p">></span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">new</span> <span class="n">User</span><span class="p">{</span><span class="n">FirstAndMiddleName</span><span class="p">=</span><span class="s">"Carson"</span> <span class="p">,</span><span class="n">LastName</span><span class="p">=</span><span class="s">"Alexander"</span> <span class="p">},</span>
</span><span class='line'> <span class="k">new</span> <span class="n">User</span><span class="p">{</span><span class="n">FirstAndMiddleName</span><span class="p">=</span><span class="s">"Meredith"</span><span class="p">,</span><span class="n">LastName</span><span class="p">=</span><span class="s">"Alonso"</span> <span class="p">},</span>
</span><span class='line'> <span class="k">new</span> <span class="n">User</span><span class="p">{</span><span class="n">FirstAndMiddleName</span><span class="p">=</span><span class="s">"Arturo"</span> <span class="p">,</span><span class="n">LastName</span><span class="p">=</span><span class="s">"Anand"</span> <span class="p">},</span>
</span><span class='line'> <span class="k">new</span> <span class="n">User</span><span class="p">{</span><span class="n">FirstAndMiddleName</span><span class="p">=</span><span class="s">"Gytis"</span> <span class="p">,</span><span class="n">LastName</span><span class="p">=</span><span class="s">"Barzdukas"</span> <span class="p">},</span>
</span><span class='line'> <span class="k">new</span> <span class="n">User</span><span class="p">{</span><span class="n">FirstAndMiddleName</span><span class="p">=</span><span class="s">"Yan"</span> <span class="p">,</span><span class="n">LastName</span><span class="p">=</span><span class="s">"Li"</span> <span class="p">},</span>
</span><span class='line'> <span class="k">new</span> <span class="n">User</span><span class="p">{</span><span class="n">FirstAndMiddleName</span><span class="p">=</span><span class="s">"Peggy"</span> <span class="p">,</span><span class="n">LastName</span><span class="p">=</span><span class="s">"Justice"</span> <span class="p">},</span>
</span><span class='line'> <span class="k">new</span> <span class="n">User</span><span class="p">{</span><span class="n">FirstAndMiddleName</span><span class="p">=</span><span class="s">"Laura"</span> <span class="p">,</span><span class="n">LastName</span><span class="p">=</span><span class="s">"Norman"</span> <span class="p">},</span>
</span><span class='line'> <span class="k">new</span> <span class="n">User</span><span class="p">{</span><span class="n">FirstAndMiddleName</span><span class="p">=</span><span class="s">"Nino"</span> <span class="p">,</span><span class="n">LastName</span><span class="p">=</span><span class="s">"Olivetto"</span> <span class="p">}</span>
</span><span class='line'> <span class="p">};</span>
</span><span class='line'>
</span><span class='line'> <span class="n">users</span><span class="p">.</span><span class="n">ForEach</span><span class="p">(</span><span class="n">aUser</span> <span class="p">=></span> <span class="n">aModel</span><span class="p">.</span><span class="n">Users</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="n">aUser</span><span class="p">));</span>
</span><span class='line'> <span class="n">aModel</span><span class="p">.</span><span class="n">SaveChanges</span><span class="p">();</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>Tell Entity Framework to use your initializer class by adding the following to the <code>Global.asax.cs</code> file as shown and the proper using statments:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'> <span class="c1">// Set Database Initializer</span>
</span><span class='line'> <span class="n">Database</span><span class="p">.</span><span class="n">SetInitializer</span><span class="p"><</span><span class="n">Model</span><span class="p">>(</span><span class="k">new</span> <span class="n">ModelInitializer</span><span class="p">());</span>
</span></code></pre></td></tr></table></div></figure>
<p>The intializer will execute on first use. If you want the initializer to execute immediately add the following code in the <code>Global.asax.cs</code> following the above. </p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'> <span class="k">using</span> <span class="p">(</span><span class="kt">var</span> <span class="n">model</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Model</span><span class="p">())</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">model</span><span class="p">.</span><span class="n">Database</span><span class="p">.</span><span class="n">Initialize</span><span class="p">(</span><span class="k">false</span><span class="p">);</span>
</span><span class='line'> <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p><code>Global.asax.cs</code> should now be as follows:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">Infrastructure</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">Entities</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Optimization</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Routing</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Data.Entity</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">MvcApplication</span> <span class="p">:</span> <span class="n">System</span><span class="p">.</span><span class="n">Web</span><span class="p">.</span><span class="n">HttpApplication</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">protected</span> <span class="k">void</span> <span class="nf">Application_Start</span><span class="p">()</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">AreaRegistration</span><span class="p">.</span><span class="n">RegisterAllAreas</span><span class="p">();</span>
</span><span class='line'> <span class="n">FilterConfig</span><span class="p">.</span><span class="n">RegisterGlobalFilters</span><span class="p">(</span><span class="n">GlobalFilters</span><span class="p">.</span><span class="n">Filters</span><span class="p">);</span>
</span><span class='line'> <span class="n">RouteConfig</span><span class="p">.</span><span class="n">RegisterRoutes</span><span class="p">(</span><span class="n">RouteTable</span><span class="p">.</span><span class="n">Routes</span><span class="p">);</span>
</span><span class='line'> <span class="n">BundleConfig</span><span class="p">.</span><span class="n">RegisterBundles</span><span class="p">(</span><span class="n">BundleTable</span><span class="p">.</span><span class="n">Bundles</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// Replace Default ViewEngine with Feature version</span>
</span><span class='line'> <span class="n">ViewEngines</span><span class="p">.</span><span class="n">Engines</span><span class="p">.</span><span class="n">Clear</span><span class="p">();</span>
</span><span class='line'> <span class="n">ViewEngines</span><span class="p">.</span><span class="n">Engines</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="k">new</span> <span class="n">FeatureRazorViewEngine</span><span class="p">());</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">//Replace Default Controller factor with Feature version</span>
</span><span class='line'> <span class="n">ControllerBuilder</span><span class="p">.</span><span class="n">Current</span><span class="p">.</span><span class="n">SetControllerFactory</span><span class="p">(</span><span class="k">new</span> <span class="n">JimmyMvc</span><span class="p">.</span><span class="n">Infrastructure</span><span class="p">.</span><span class="n">ControllerFactory</span><span class="p">());</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// Set Database Initializer</span>
</span><span class='line'> <span class="n">Database</span><span class="p">.</span><span class="n">SetInitializer</span><span class="p"><</span><span class="n">Model</span><span class="p">>(</span><span class="k">new</span> <span class="n">ModelInitializer</span><span class="p">());</span>
</span><span class='line'>
</span><span class='line'> <span class="k">using</span> <span class="p">(</span><span class="kt">var</span> <span class="n">model</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Model</span><span class="p">())</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">model</span><span class="p">.</span><span class="n">Database</span><span class="p">.</span><span class="n">Initialize</span><span class="p">(</span><span class="n">force</span><span class="p">:</span> <span class="k">false</span><span class="p">);</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>Execute the application now. And the database should be created and populated with data.</p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/DatabaseCreated.png" alt="Database Created"></p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/UserData.png" alt="Database Created"></p>
<p>Lets get started implementing our first Feature and building the infrastructure needed to support it. </p>
<h2>Feature 1: Display the list of users ##</h2>
<p>The url for the Feature will be <code>/User/Index</code></p>
<p>We will store all of the Features in the Features folder organized by the Entity/Aggregate root of which they are associated. So add a <code>User</code> folder under the Features folder.</p>
<p><img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/UserFolder.png" alt="Database Created"></p>
<p>Add a class named <code>Index</code> to the <code>User</code> folder. This will contain the Features logic.</p>
<p>Add an <code>Index</code> view by right clicking on the <code>User</code> folder and selecting <code>Add->MVC 5 View Page (Razor)</code> </p>
<p>Nest the <code>Index.cshtml</code> file under the <code>Index.cs</code> file to keep the solution organized, using the <a href="https://visualstudiogallery.msdn.microsoft.com/3ebde8fb-26d8-4374-a0eb-1e4e2665070c">File Nesting</a> add-in. </p>
<p>Replace the default <code>index.cshtml</code> code with the following temporary code which is just used so we can see something when the view renders. We will update this later.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="p"><</span><span class="n">div</span><span class="p">></span>
</span><span class='line'> <span class="n">List</span> <span class="n">of</span> <span class="n">Users</span>
</span><span class='line'><span class="p"></</span><span class="n">div</span><span class="p">></span>
</span></code></pre></td></tr></table></div></figure>
<p>Add a link to the main menu in the <code>Features\Shared\_Layout.cshtml</code> to the Users page.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="p">...</span>
</span><span class='line'><span class="p"><</span><span class="n">li</span><span class="p">></span><span class="n">@Html</span><span class="p">.</span><span class="n">ActionLink</span><span class="p">(</span><span class="s">"Users"</span><span class="p">,</span> <span class="s">"Index"</span><span class="p">,</span> <span class="s">"User"</span><span class="p">)</</span><span class="n">li</span><span class="p">></span>
</span><span class='line'><span class="p">...</span>
</span></code></pre></td></tr></table></div></figure>
<p>Now add a controller to the Feature.</p>
<p>Nested inside the Index class add a controller. </p>
<p>Given that each feature now represents a single url the name of the controller method no longer needs to correspond to the url as there can only be one method for <code>get</code> and one for <code>post</code> on each controller. So we will name all of our methods "Action" and thus give us the opportunity to be more DRY. A controller class now can represent a single url. We will use this knowledge later when we create a <code>LinkBuilder</code> class.</p>
<p>Your <code>User\Index.cs</code> file should be as follows:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Features.User</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">Index</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">UiController</span> <span class="p">:</span> <span class="n">Controller</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">public</span> <span class="k">virtual</span> <span class="n">ActionResult</span> <span class="nf">Action</span><span class="p">()</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">return</span> <span class="nf">View</span><span class="p">();</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>Execute the app and attempt to navigate to the Users page. <img src="http://steventcramer.github.io//assets/pictures/jimmy-mvc/UsersLink.png" alt="Users page"></p>
<p>You will get <code>The resource cannot be found.</code> error. This is because the controller can not be found using our Controller Factory. The current factory is looking for a controller of type "JimmyMvc.Features.User.UiController" and an method named "Index".</p>
<p>Our controllers fully qualified name is "JimmyMvc.Features.User.Index+UiController" because we have embedded it inside the feature. So we either have to change the factory, or not embed the controller. Having done this both ways I chose to embed the controller as this allows for a more <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a> solution. Also the method we are looking for is always named <code>Action</code> we will address this also in the controller factory.</p>
<p>So let's update the factory.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Infrastructure</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc.Async</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Routing</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">ControllerFactory</span> <span class="p">:</span> <span class="n">DefaultControllerFactory</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">protected</span> <span class="k">override</span> <span class="n">Type</span> <span class="nf">GetControllerType</span><span class="p">(</span><span class="n">RequestContext</span> <span class="n">aRequestContext</span><span class="p">,</span> <span class="kt">string</span> <span class="n">aControllerName</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="kt">string</span> <span class="n">action</span> <span class="p">=</span> <span class="n">aRequestContext</span><span class="p">.</span><span class="n">RouteData</span><span class="p">.</span><span class="n">GetRequiredString</span><span class="p">(</span><span class="n">valueName</span><span class="p">:</span> <span class="s">"action"</span><span class="p">);</span>
</span><span class='line'> <span class="kt">string</span> <span class="n">typeName</span> <span class="p">=</span> <span class="s">"JimmyMvc.Features."</span> <span class="p">+</span> <span class="n">aControllerName</span> <span class="p">+</span> <span class="s">"."</span> <span class="p">+</span> <span class="n">action</span> <span class="p">+</span> <span class="s">"+UiController"</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'> <span class="n">System</span><span class="p">.</span><span class="n">Reflection</span><span class="p">.</span><span class="n">Assembly</span> <span class="n">assembly</span> <span class="p">=</span> <span class="k">typeof</span><span class="p">(</span><span class="n">ControllerFactory</span><span class="p">).</span><span class="n">Assembly</span><span class="p">;</span>
</span><span class='line'> <span class="n">Type</span> <span class="n">type</span> <span class="p">=</span> <span class="n">assembly</span><span class="p">.</span><span class="n">GetType</span><span class="p">(</span><span class="n">typeName</span><span class="p">);</span>
</span><span class='line'> <span class="k">return</span> <span class="n">type</span><span class="p">;</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">override</span> <span class="n">IController</span> <span class="nf">CreateController</span><span class="p">(</span><span class="n">RequestContext</span> <span class="n">aRequestContext</span><span class="p">,</span> <span class="kt">string</span> <span class="n">aControllerName</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">IController</span> <span class="n">controller</span> <span class="p">=</span> <span class="k">base</span><span class="p">.</span><span class="n">CreateController</span><span class="p">(</span><span class="n">aRequestContext</span><span class="p">,</span> <span class="n">aControllerName</span><span class="p">);</span>
</span><span class='line'> <span class="k">return</span> <span class="nf">ReplaceActionInvoker</span><span class="p">(</span><span class="n">controller</span><span class="p">);</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">private</span> <span class="n">IController</span> <span class="nf">ReplaceActionInvoker</span><span class="p">(</span><span class="n">IController</span> <span class="n">aController</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="kt">var</span> <span class="n">mvcController</span> <span class="p">=</span> <span class="n">aController</span> <span class="k">as</span> <span class="n">Controller</span><span class="p">;</span>
</span><span class='line'> <span class="k">if</span> <span class="p">(</span><span class="n">mvcController</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">mvcController</span><span class="p">.</span><span class="n">ActionInvoker</span> <span class="p">=</span> <span class="k">new</span> <span class="n">FeatureActionInvoker</span><span class="p">();</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">return</span> <span class="n">aController</span><span class="p">;</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">public</span> <span class="k">class</span> <span class="nc">FeatureActionInvoker</span> <span class="p">:</span> <span class="n">AsyncControllerActionInvoker</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">protected</span> <span class="k">override</span> <span class="n">ActionDescriptor</span> <span class="nf">FindAction</span><span class="p">(</span><span class="n">ControllerContext</span> <span class="n">aControllerContext</span><span class="p">,</span> <span class="n">ControllerDescriptor</span> <span class="n">aControllerDescriptor</span><span class="p">,</span> <span class="kt">string</span> <span class="n">aActionName</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">return</span> <span class="k">base</span><span class="p">.</span><span class="n">FindAction</span><span class="p">(</span><span class="n">aControllerContext</span><span class="p">,</span> <span class="n">aControllerDescriptor</span><span class="p">,</span> <span class="n">actionName</span><span class="p">:</span> <span class="s">"Action"</span><span class="p">);</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>Executing the application and navigating to the home url (Home/Index) will now give "The resource cannot be found." but when you manually enter /User/Index you should see the view page.</p>
<p>So let's fix the <code>Home/About</code>, <code>Home/Contact</code>, <code>Home/Index</code> Features </p>
<p>under <code>Features\Home</code> Create classes named <code>About</code>, <code>Contact</code> and <code>Index</code>.</p>
<p>Take the existing controller and split it up among the respective classes.</p>
<p>The Existing Controller: </p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">namespace</span> <span class="nn">JimmyMvc.Features.Home</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Linq</span><span class="p">;</span>
</span><span class='line'> <span class="k">using</span> <span class="nn">System.Web.Mvc</span><span class="p">;</span>
</span><span class='line'>