+
+ @Html.ActionLink("Cancel", "Index", null, new {@class = "btn"})
+
+
+}
<#
// The following code closes the asp:Content tag used in the case of a master page and the body and html tags in the case of a regular view page
#>
diff --git a/BlankMVCProject/BlankMVCProject/CodeTemplates/AddView/CSHTML/Details.tt b/BlankMVCProject/BlankMVCProject/CodeTemplates/AddView/CSHTML/Details.tt
index 3a83a7a..ec05c39 100644
--- a/BlankMVCProject/BlankMVCProject/CodeTemplates/AddView/CSHTML/Details.tt
+++ b/BlankMVCProject/BlankMVCProject/CodeTemplates/AddView/CSHTML/Details.tt
@@ -25,7 +25,7 @@ if(mvcHost.IsPartialView) {
#>
@{
- ViewBag.Title = "<#= mvcHost.ViewName#>";
+ ViewBag.Title = "<#= mvcHost.ViewDataType.Name + " " + mvcHost.ViewName#>";
<#
if (!String.IsNullOrEmpty(mvcHost.MasterPageFile)) {
#>
@@ -34,11 +34,6 @@ if (!String.IsNullOrEmpty(mvcHost.MasterPageFile)) {
}
#>
}
-
-
+
+
+
+<#
+// The following code closes the asp:Content tag used in the case of a master page and the body and html tags in the case of a regular view page
+#>
+<#
+if(mvcHost.IsContentPage) {
+#>
+<#
+} else if(!mvcHost.IsPartialView && !mvcHost.IsContentPage) {
+ ClearIndent();
+#>
+
+
+<#
+}
+#>
+
+<#+
+// Describes the information about a property on the model
+class ModelProperty {
+ public string Name { get; set; }
+ public string ValueExpression { get; set; }
+ public Type UnderlyingType { get; set; }
+ public bool IsPrimaryKey { get; set; }
+ public bool IsReadOnly { get; set; }
+ public string DisplayName { get; set; }
+}
+
+// Change this list to include any non-primitive types you think should be eligible for display/edit
+static Type[] bindableNonPrimitiveTypes = new[] {
+ typeof(string),
+ typeof(decimal),
+ typeof(Guid),
+ typeof(DateTime),
+ typeof(DateTimeOffset),
+ typeof(TimeSpan),
+ typeof(bool)
+};
+
+// Call this to get the list of properties in the model. Change this to modify or add your
+// own default formatting for display values.
+List GetModelProperties(Type type) {
+ List results = GetEligibleProperties(type);
+
+ foreach (ModelProperty prop in results) {
+ if (prop.UnderlyingType == typeof(double) || prop.UnderlyingType == typeof(decimal)) {
+ prop.ValueExpression = "String.Format(\"{0:F}\", " + prop.ValueExpression + ")";
+ }
+ else if (prop.UnderlyingType == typeof(DateTime)) {
+ prop.ValueExpression = "String.Format(\"{0:g}\", " + prop.ValueExpression + ")";
+ }
+ }
+
+ return results;
+}
+
+// Call this to determine if the property represents a primary key. Change the
+// code to change the definition of primary key.
+bool IsPrimaryKey(PropertyInfo property) {
+ if (string.Equals(property.Name, "id", StringComparison.OrdinalIgnoreCase)) { // EF Code First convention
+ return true;
+ }
+
+ if (string.Equals(property.Name, property.DeclaringType.Name + "id", StringComparison.OrdinalIgnoreCase)) { // EF Code First convention
+ return true;
+ }
+
+ foreach (object attribute in property.GetCustomAttributes(true)) {
+ if (attribute is KeyAttribute) { // WCF RIA Services and EF Code First explicit
+ return true;
+ }
+
+ var edmScalar = attribute as EdmScalarPropertyAttribute;
+ if (edmScalar != null && edmScalar.EntityKeyProperty) { // EF traditional
+ return true;
+ }
+
+ var column = attribute as ColumnAttribute;
+ if (column != null && column.IsPrimaryKey) { // LINQ to SQL
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// This will return the primary key property name, if and only if there is exactly
+// one primary key. Returns null if there is no PK, or the PK is composite.
+string GetPrimaryKeyName(Type type) {
+ IEnumerable pkNames = GetPrimaryKeyNames(type);
+ return pkNames.Count() == 1 ? pkNames.First() : null;
+}
+
+// This will return all the primary key names. Will return an empty list if there are none.
+IEnumerable GetPrimaryKeyNames(Type type) {
+ return GetEligibleProperties(type).Where(mp => mp.IsPrimaryKey).Select(mp => mp.Name);
+}
+
+// Helper
+List GetEligibleProperties(Type type) {
+ List results = new List();
+
+ foreach (PropertyInfo prop in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
+ Type underlyingType = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
+ if (prop.GetGetMethod() != null && prop.GetIndexParameters().Length == 0 && IsBindableType(underlyingType)) {
+ results.Add(new ModelProperty {
+ Name = prop.Name,
+ ValueExpression = "Model." + prop.Name,
+ UnderlyingType = underlyingType,
+ IsPrimaryKey = IsPrimaryKey(prop),
+ IsReadOnly = prop.GetSetMethod() == null,
+ DisplayName = GetDisplayName(prop)
+ });
+ }
+ }
+
+ return results;
+}
+
+// Helper
+bool IsBindableType(Type type) {
+ return type.IsPrimitive || bindableNonPrimitiveTypes.Contains(type);
+}
+
+// Helper
+string GetDisplayName(PropertyInfo property) {
+ string displayName = null;
+
+ foreach (object attribute in property.GetCustomAttributes(true)) {
+ if (attribute is DisplayAttribute) {
+ DisplayAttribute display = attribute as DisplayAttribute;
+ if (display != null) {
+ displayName = display.Name;
+ }
+ }
+
+ }
+
+ return displayName;
+}
+#>
\ No newline at end of file
diff --git a/BlankMVCProject/BlankMVCProject/CodeTemplates/AddView/CSHTML/List.tt b/BlankMVCProject/BlankMVCProject/CodeTemplates/AddView/CSHTML/List.tt
index cba69e0..d466f76 100644
--- a/BlankMVCProject/BlankMVCProject/CodeTemplates/AddView/CSHTML/List.tt
+++ b/BlankMVCProject/BlankMVCProject/CodeTemplates/AddView/CSHTML/List.tt
@@ -25,7 +25,7 @@ if(mvcHost.IsPartialView) {
#>
@{
- ViewBag.Title = "<#= mvcHost.ViewName#>";
+ ViewBag.Title = "<#= mvcHost.ViewDataType.Name + " List"#>";
<#
if (!String.IsNullOrEmpty(mvcHost.MasterPageFile)) {
#>
@@ -36,7 +36,7 @@ if (!String.IsNullOrEmpty(mvcHost.MasterPageFile)) {
}
").addClass('calendar');
+
+ // Populate day of week headers, realigned by startOfWeek.
+ for (var i = 0; i < this.shortDayNames.length; i++) {
+ $calendar.append('
'},a.fn.typeahead.Constructor=b,a(function(){a("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);if(c.data("typeahead"))return;b.preventDefault(),c.typeahead(c.data())})})}(window.jQuery);
\ No newline at end of file
diff --git a/BlankMVCProject/BlankMVCProject/Scripts/jquery.dataTables.min.js b/BlankMVCProject/BlankMVCProject/Scripts/jquery.dataTables.min.js
new file mode 100644
index 0000000..bbbddb5
--- /dev/null
+++ b/BlankMVCProject/BlankMVCProject/Scripts/jquery.dataTables.min.js
@@ -0,0 +1,153 @@
+/*
+ * File: jquery.dataTables.min.js
+ * Version: 1.9.0
+ * Author: Allan Jardine (www.sprymedia.co.uk)
+ * Info: www.datatables.net
+ *
+ * Copyright 2008-2012 Allan Jardine, all rights reserved.
+ *
+ * This source file is free software, under either the GPL v2 license or a
+ * BSD style license, available at:
+ * http://datatables.net/license_gpl2
+ * http://datatables.net/license_bsd
+ *
+ * This source file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
+ */
+(function(i,aa,k,l){var j=function(e){function o(a,b){var c=j.defaults.columns,d=a.aoColumns.length,c=i.extend({},j.models.oColumn,c,{sSortingClass:a.oClasses.sSortable,sSortingClassJUI:a.oClasses.sSortJUI,nTh:b?b:k.createElement("th"),sTitle:c.sTitle?c.sTitle:b?b.innerHTML:"",aDataSort:c.aDataSort?c.aDataSort:[d],mDataProp:c.mDataProp?c.oDefaults:d});a.aoColumns.push(c);if(a.aoPreSearchCols[d]===l||null===a.aoPreSearchCols[d])a.aoPreSearchCols[d]=i.extend({},j.models.oSearch);else{c=a.aoPreSearchCols[d];
+if(c.bRegex===l)c.bRegex=!0;if(c.bSmart===l)c.bSmart=!0;if(c.bCaseInsensitive===l)c.bCaseInsensitive=!0}E(a,d,null)}function E(a,b,c){b=a.aoColumns[b];if(c!==l&&null!==c){if(c.sType!==l)b.sType=c.sType,b._bAutoType=!1;i.extend(b,c);n(b,c,"sWidth","sWidthOrig");if(c.iDataSort!==l)b.aDataSort=[c.iDataSort];n(b,c,"aDataSort")}b.fnGetData=V(b.mDataProp);b.fnSetData=sa(b.mDataProp);if(!a.oFeatures.bSort)b.bSortable=!1;if(!b.bSortable||-1==i.inArray("asc",b.asSorting)&&-1==i.inArray("desc",b.asSorting))b.sSortingClass=
+a.oClasses.sSortableNone,b.sSortingClassJUI="";else if(b.bSortable||-1==i.inArray("asc",b.asSorting)&&-1==i.inArray("desc",b.asSorting))b.sSortingClass=a.oClasses.sSortable,b.sSortingClassJUI=a.oClasses.sSortJUI;else if(-1!=i.inArray("asc",b.asSorting)&&-1==i.inArray("desc",b.asSorting))b.sSortingClass=a.oClasses.sSortableAsc,b.sSortingClassJUI=a.oClasses.sSortJUIAscAllowed;else if(-1==i.inArray("asc",b.asSorting)&&-1!=i.inArray("desc",b.asSorting))b.sSortingClass=a.oClasses.sSortableDesc,b.sSortingClassJUI=
+a.oClasses.sSortJUIDescAllowed}function r(a){if(!1===a.oFeatures.bAutoWidth)return!1;ba(a);for(var b=0,c=a.aoColumns.length;bm[h])d(a.aoColumns.length+m[h],b[f]);else if("string"===typeof m[h])for(e=0,q=a.aoColumns.length;eb&&a[d]--; -1!=c&&a.splice(c,
+1)}function R(a,b,c){var d=a.aoColumns[c];return d.fnRender({iDataRow:b,iDataColumn:c,oSettings:a,aData:a.aoData[b]._aData,mDataProp:d.mDataProp},w(a,b,c,"display"))}function ca(a,b){var c=a.aoData[b],d;if(null===c.nTr){c.nTr=k.createElement("tr");c.nTr._DT_RowIndex=b;if(c._aData.DT_RowId)c.nTr.id=c._aData.DT_RowId;c._aData.DT_RowClass&&i(c.nTr).addClass(c._aData.DT_RowClass);for(var f=0,h=a.aoColumns.length;f=a.fnRecordsDisplay()?0:a.iInitDisplayStart,a.iInitDisplayStart=-1,z(a);if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++;else if(a.oFeatures.bServerSide){if(!a.bDestroying&&!va(a))return}else a.iDraw++;if(0!==a.aiDisplay.length){var g=a._iDisplayStart;c=a._iDisplayEnd;if(a.oFeatures.bServerSide)g=0,c=a.aoData.length;for(;g