+ <%: Html.ActionLink("Back to List", "Index") %>
+
+<#
+// 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(Model.IsContentPage) {
+#>
+
+
+<#
+ foreach(string cphid in Model.SectionNames) {
+ if(!cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase) && !cphid.Equals(Model.PrimarySectionName, StringComparison.OrdinalIgnoreCase)) {
+ CPHCounter++;
+#>
+
+
+
+<#
+ }
+ }
+#>
+<#
+} else if(!Model.IsContentPage) {
+ ClearIndent();
+#>
+
+
+<#
+}
+#>
+
+<#+
+// Describes the information about a property on the model
+class ModelProperty {
+ public string Name { get; set; }
+ public string ValueExpression { get; set; }
+ public EnvDTE.CodeTypeRef Type { get; set; }
+ public bool IsPrimaryKey { get; set; }
+ public bool IsForeignKey { get; set; }
+ public bool IsReadOnly { get; set; }
+}
+
+// Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+static Type[] bindableNonPrimitiveTypes = new[] {
+ typeof(string),
+ typeof(decimal),
+ typeof(Guid),
+ typeof(DateTime),
+ typeof(DateTimeOffset),
+ typeof(TimeSpan),
+};
+
+// 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(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = GetEligibleProperties(typeInfo, includeUnbindableProperties);
+
+ foreach (ModelProperty prop in results) {
+ if (prop.Type.UnderlyingTypeIs() || prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:F}\", " + prop.ValueExpression + ")";
+ }
+ else if (prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:g}\", " + prop.ValueExpression + ")";
+ }
+ else if (!IsBindableType(prop.Type)) {
+ prop.ValueExpression = GetValueExpression("Model." + prop.Name, (EnvDTE.CodeType)prop.Type.CodeType);
+ }
+ }
+
+ return results;
+}
+
+// Change this list to include the names of properties that should be selected to represent an entity as a single string
+static string[] displayPropertyNames = new[] { "Name", "Title", "LastName", "Surname", "Subject", "Count" };
+
+string GetValueExpression(string propertyExpression, EnvDTE.CodeType propertyType) {
+ if (propertyType != null) {
+ var chosenSubproperty = propertyType.DisplayColumnProperty() ?? propertyType.FindProperty(displayPropertyNames);
+ if (chosenSubproperty != null) {
+ var toStringSuffix = chosenSubproperty.Type.AsFullName == "System.String" ? "" : ".ToString()";
+ return String.Format("({0} == null ? \"None\" : {0}.{1}{2})", propertyExpression, chosenSubproperty.Name, toStringSuffix);
+ }
+ }
+ return "Html.DisplayTextFor(_ => " + propertyExpression + ").ToString()";
+}
+
+// Helper
+List GetEligibleProperties(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = new List();
+ if (typeInfo != null) {
+ foreach (var prop in typeInfo.VisibleMembers().OfType()) {
+ if (prop.IsReadable() && !prop.HasIndexParameters() && (includeUnbindableProperties || IsBindableType(prop.Type))) {
+ results.Add(new ModelProperty {
+ Name = prop.Name,
+ ValueExpression = "Model." + prop.Name,
+ Type = prop.Type,
+ IsPrimaryKey = Model.PrimaryKeyName == prop.Name,
+ IsForeignKey = ParentRelations.Any(x => x.RelationProperty == prop),
+ IsReadOnly = !prop.IsWriteable()
+ });
+ }
+ }
+ }
+
+ return results;
+}
+
+IEnumerable ParentRelations {
+ get { return ((IEnumerable)Model.RelatedEntities).OfType().Where(x => x.RelationType == RelationType.Parent); }
+}
+
+// Helper
+bool IsBindableType(EnvDTE.CodeTypeRef type) {
+ return type.UnderlyingIsPrimitive() || bindableNonPrimitiveTypes.Any(x => type.UnderlyingTypeIs(x));
+}
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Create.vb.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Create.vb.t4
new file mode 100644
index 0000000..98ecf2b
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Create.vb.t4
@@ -0,0 +1,200 @@
+<#@ Template Language="VB" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="aspx" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<#@ import namespace="EnvDTE" #>
+<#
+Dim viewDataType = CType(Model.ViewDataType, CodeType)
+Dim mvcViewDataTypeGenericString As String = If(viewDataType IsNot Nothing, "(Of " & viewDataType.FullName & ")", String.Empty)
+Dim CPHCounter As Integer = 1
+#>
+<#
+If Model.IsContentPage Then
+#>
+<%@ Page Title="" Language="VB" MasterPageFile="~<#= Model.Layout #>" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+<#
+ For Each cphid As String In Model.SectionNames
+ If cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase) Then
+#>
+
+ <#= Model.ViewName #>
+
+
+<#
+ CPHCounter += 1
+ End If
+ Next
+#>
+
+
+
<#= Model.ViewName #>
+
+<#
+Else
+#>
+<%@ Page Language="VB" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+
+
+
+ <#= Model.ViewName #>
+
+
+<#
+ PushIndent(" ")
+End If
+#>
+<%-- The following line works around an ASP.NET compiler warning --%>
+<%: "" %>
+
+<# If Model.ReferenceScriptLibraries Then #>
+<# If Not Model.IsContentPage Then #>
+
+<# End If #>
+
+
+
+<# End If #>
+<% Using Html.BeginForm() %>
+ <%: Html.ValidationSummary(True) %>
+
+<% End Using %>
+
+
+ <%: Html.ActionLink("Back to List", "Index") %>
+
+<#
+' 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 Model.IsContentPage
+#>
+
+
+<#
+ For Each cphid As String In Model.SectionNames
+ If String.Compare(cphid, "TitleContent", StringComparison.OrdinalIgnoreCase) <> 0 AndAlso String.Compare(cphid, Model.PrimarySectionName, StringComparison.OrdinalIgnoreCase) <> 0 Then
+ CPHCounter +=1
+#>
+
+
+
+<#
+ End If
+ Next
+#>
+<#
+Else If Not Model.IsContentPage Then
+ ClearIndent()
+#>
+
+
+<#
+End If
+#>
+
+<#+
+' Describes the information about a property on the model
+Private Class ModelProperty
+ Public Name As String
+ Public ValueExpression As String
+ Public Type As CodeTypeRef
+ Public IsReadOnly As Boolean
+ Public IsPrimaryKey As Boolean
+ Public IsForeignKey As Boolean
+End Class
+
+' Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+Private Shared bindableNonPrimitiveTypes As Type() = New Type() {
+ GetType(String),
+ GetType(Decimal),
+ GetType(Guid),
+ GetType(DateTime),
+ GetType(DateTimeOffset),
+ GetType(TimeSpan)
+}
+
+' Call this to get the list of properties in the model. Change this to modify or add your
+' own default formatting for display values.
+Private Function GetModelProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As List(Of ModelProperty) = GetEligibleProperties(type, includeUnbindableProperties)
+
+ For Each modelProp As ModelProperty In results
+ If ((modelProp.Type.UnderlyingTypeIs(GetType(Double))) OrElse (modelProp.Type.UnderlyingTypeIs(GetType(Decimal)))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:F}"", " & modelProp.ValueExpression & ")")
+ ElseIf (modelProp.Type.UnderlyingTypeIs(GetType(DateTime))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:g}"", " & modelProp.ValueExpression & ")")
+ ElseIf (Not IsBindableType(modelProp.Type))
+ modelProp.ValueExpression = GetValueExpression("Model." & modelProp.Name, CType(modelProp.Type.CodeType, CodeType))
+ End If
+ Next
+
+ Return results
+End Function
+
+' Change this list to include the names of properties that should be selected to represent an entity as a single string
+Private Shared displayPropertyNames As String() = New String() { "Name", "Title", "LastName", "Surname", "Subject", "Count" }
+
+Private Function GetValueExpression(ByVal propertyExpression As String, ByVal propertyType As CodeType) As String
+ If propertyType IsNot Nothing Then
+ Dim chosenSubproperty = If(propertyType.DisplayColumnProperty(), propertyType.FindProperty(displayPropertyNames))
+ If chosenSubproperty IsNot Nothing Then
+ Dim toStringSuffix = If(chosenSubproperty.Type.AsFullName = "System.String", "", ".ToString()")
+ Return String.Format("(If({0} Is Nothing, ""None"", {0}.{1}{2}))", propertyExpression, chosenSubproperty.Name, toStringSuffix)
+ End If
+ End If
+ Return "Html.DisplayTextFor(Function(model) " & propertyExpression & ").ToString()"
+End Function
+
+' Helper
+Private Function GetEligibleProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As New List(Of ModelProperty)
+
+ If type IsNot Nothing Then
+ For Each prop As CodeProperty In type.VisibleMembers().OfType(Of CodeProperty)()
+ Dim propValue = prop
+ If (prop.IsReadable() AndAlso (Not prop.HasIndexParameters()) AndAlso (includeUnbindableProperties OrElse IsBindableType(prop.Type))) Then
+ results.Add(New ModelProperty() With { _
+ .Name = prop.Name, _
+ .ValueExpression = ("Model." & prop.Name), _
+ .Type = prop.Type, _
+ .IsPrimaryKey = Model.PrimaryKeyName = prop.Name, _
+ .IsReadOnly = Not prop.IsWriteable(), _
+ .IsForeignKey = ParentRelations.Any(Function(x) propValue.Name = x.RelationProperty.Name) _
+ })
+ End If
+ Next
+ End If
+
+ Return results
+End Function
+
+Private ReadOnly Property ParentRelations As IEnumerable(Of RelatedEntityInfo)
+ Get
+ Return CType(Model.RelatedEntities, IEnumerable).OfType(Of RelatedEntityInfo)().Where(Function(x) x.RelationType = RelationType.Parent)
+ End Get
+End Property
+
+' Helper
+Private Function IsBindableType(ByVal type As CodeTypeRef) As Boolean
+ Return type.UnderlyingIsPrimitive() OrElse bindableNonPrimitiveTypes.Any(Function(x) type.UnderlyingTypeIs(x))
+End Function
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/CreateOrEdit.cs.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/CreateOrEdit.cs.t4
new file mode 100644
index 0000000..11d19be
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/CreateOrEdit.cs.t4
@@ -0,0 +1,138 @@
+<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="ascx" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<#
+ var viewDataType = (EnvDTE.CodeType) Model.ViewDataType;
+ var mvcViewDataTypeGenericString = (viewDataType != null) ? "<" + viewDataType.FullName + ">" : "";
+#>
+<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<#= mvcViewDataTypeGenericString #>" %>
+
+<#
+foreach (ModelProperty property in GetModelProperties(Model.ViewDataType, false)) {
+ if (!property.IsPrimaryKey && !property.IsForeignKey && !property.IsReadOnly) {
+#>
+
+<# Next #><#+
+' Describes the information about a property on the model
+Private Class ModelProperty
+ Public Name As String
+ Public ValueExpression As String
+ Public Type As CodeTypeRef
+ Public IsReadOnly As Boolean
+ Public IsPrimaryKey As Boolean
+ Public IsForeignKey As Boolean
+End Class
+
+' Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+Private Shared bindableNonPrimitiveTypes As Type() = New Type() {
+ GetType(String),
+ GetType(Decimal),
+ GetType(Guid),
+ GetType(DateTime),
+ GetType(DateTimeOffset),
+ GetType(TimeSpan)
+}
+
+' Call this to get the list of properties in the model. Change this to modify or add your
+' own default formatting for display values.
+Private Function GetModelProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As List(Of ModelProperty) = GetEligibleProperties(type, includeUnbindableProperties)
+
+ For Each modelProp As ModelProperty In results
+ If ((modelProp.Type.UnderlyingTypeIs(GetType(Double))) OrElse (modelProp.Type.UnderlyingTypeIs(GetType(Decimal)))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:F}"", " & modelProp.ValueExpression & ")")
+ ElseIf (modelProp.Type.UnderlyingTypeIs(GetType(DateTime))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:g}"", " & modelProp.ValueExpression & ")")
+ ElseIf (Not IsBindableType(modelProp.Type))
+ modelProp.ValueExpression = GetValueExpression("Model." & modelProp.Name, CType(modelProp.Type.CodeType, CodeType))
+ End If
+ Next
+
+ Return results
+End Function
+
+' Change this list to include the names of properties that should be selected to represent an entity as a single string
+Private Shared displayPropertyNames As String() = New String() { "Name", "Title", "LastName", "Surname", "Subject", "Count" }
+
+Private Function GetValueExpression(ByVal propertyExpression As String, ByVal propertyType As CodeType) As String
+ If propertyType IsNot Nothing Then
+ Dim chosenSubproperty = If(propertyType.DisplayColumnProperty(), propertyType.FindProperty(displayPropertyNames))
+ If chosenSubproperty IsNot Nothing Then
+ Dim toStringSuffix = If(chosenSubproperty.Type.AsFullName = "System.String", "", ".ToString()")
+ Return String.Format("(If({0} Is Nothing, ""None"", {0}.{1}{2}))", propertyExpression, chosenSubproperty.Name, toStringSuffix)
+ End If
+ End If
+ Return "Html.DisplayTextFor(Function(model) " & propertyExpression & ").ToString()"
+End Function
+
+' Helper
+Private Function GetEligibleProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As New List(Of ModelProperty)
+
+ If type IsNot Nothing Then
+ For Each prop As CodeProperty In type.VisibleMembers().OfType(Of CodeProperty)()
+ Dim propValue = prop
+ If (prop.IsReadable() AndAlso (Not prop.HasIndexParameters()) AndAlso (includeUnbindableProperties OrElse IsBindableType(prop.Type))) Then
+ results.Add(New ModelProperty() With { _
+ .Name = prop.Name, _
+ .ValueExpression = ("Model." & prop.Name), _
+ .Type = prop.Type, _
+ .IsPrimaryKey = Model.PrimaryKeyName = prop.Name, _
+ .IsReadOnly = Not prop.IsWriteable(), _
+ .IsForeignKey = ParentRelations.Any(Function(x) propValue.Name = x.RelationProperty.Name) _
+ })
+ End If
+ Next
+ End If
+
+ Return results
+End Function
+
+Private ReadOnly Property ParentRelations As IEnumerable(Of RelatedEntityInfo)
+ Get
+ Return CType(Model.RelatedEntities, IEnumerable).OfType(Of RelatedEntityInfo)().Where(Function(x) x.RelationType = RelationType.Parent)
+ End Get
+End Property
+
+' Helper
+Private Function IsBindableType(ByVal type As CodeTypeRef) As Boolean
+ Return type.UnderlyingIsPrimitive() OrElse bindableNonPrimitiveTypes.Any(Function(x) type.UnderlyingTypeIs(x))
+End Function
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Delete.cs.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Delete.cs.t4
new file mode 100644
index 0000000..5d4ea9e
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Delete.cs.t4
@@ -0,0 +1,193 @@
+<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="aspx" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<# var viewDataType = (EnvDTE.CodeType) Model.ViewDataType; #>
+<#
+string mvcViewDataTypeGenericString = (viewDataType != null) ? "<" + viewDataType.FullName + ">" : "";
+int CPHCounter = 1;
+#>
+<#
+if(Model.IsContentPage) {
+#>
+<%@ Page Title="" Language="C#" MasterPageFile="~<#= Model.Layout #>" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+<#
+ foreach(string cphid in Model.SectionNames) {
+ if(cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase)) {
+#>
+
+ <#= Model.ViewName #>
+
+
+<#
+ CPHCounter++;
+ }
+ }
+#>
+
+
+
+ |
+ <%: Html.ActionLink("Back to List", "Index") %>
+
+<% End Using %>
+
+<#
+' 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 Model.IsContentPage
+#>
+
+<#
+ For Each cphid As String In Model.SectionNames
+ If String.Compare(cphid, "TitleContent", StringComparison.OrdinalIgnoreCase) <> 0 AndAlso String.Compare(cphid, Model.PrimarySectionName, StringComparison.OrdinalIgnoreCase) <> 0 Then
+ CPHCounter +=1
+#>
+
+
+
+<#
+ End If
+ Next
+#>
+<#
+Else If Not Model.IsContentPage Then
+ ClearIndent()
+#>
+
+
+<#
+End If
+#>
+
+<#+
+' Describes the information about a property on the model
+Private Class ModelProperty
+ Public Name As String
+ Public ValueExpression As String
+ Public Type As CodeTypeRef
+ Public IsReadOnly As Boolean
+ Public IsPrimaryKey As Boolean
+ Public IsForeignKey As Boolean
+End Class
+
+' Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+Private Shared bindableNonPrimitiveTypes As Type() = New Type() {
+ GetType(String),
+ GetType(Decimal),
+ GetType(Guid),
+ GetType(DateTime),
+ GetType(DateTimeOffset),
+ GetType(TimeSpan)
+}
+
+' Call this to get the list of properties in the model. Change this to modify or add your
+' own default formatting for display values.
+Private Function GetModelProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As List(Of ModelProperty) = GetEligibleProperties(type, includeUnbindableProperties)
+
+ For Each modelProp As ModelProperty In results
+ If ((modelProp.Type.UnderlyingTypeIs(GetType(Double))) OrElse (modelProp.Type.UnderlyingTypeIs(GetType(Decimal)))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:F}"", " & modelProp.ValueExpression & ")")
+ ElseIf (modelProp.Type.UnderlyingTypeIs(GetType(DateTime))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:g}"", " & modelProp.ValueExpression & ")")
+ ElseIf (Not IsBindableType(modelProp.Type))
+ modelProp.ValueExpression = GetValueExpression("Model." & modelProp.Name, CType(modelProp.Type.CodeType, CodeType))
+ End If
+ Next
+
+ Return results
+End Function
+
+' Change this list to include the names of properties that should be selected to represent an entity as a single string
+Private Shared displayPropertyNames As String() = New String() { "Name", "Title", "LastName", "Surname", "Subject", "Count" }
+
+Private Function GetValueExpression(ByVal propertyExpression As String, ByVal propertyType As CodeType) As String
+ If propertyType IsNot Nothing Then
+ Dim chosenSubproperty = If(propertyType.DisplayColumnProperty(), propertyType.FindProperty(displayPropertyNames))
+ If chosenSubproperty IsNot Nothing Then
+ Dim toStringSuffix = If(chosenSubproperty.Type.AsFullName = "System.String", "", ".ToString()")
+ Return String.Format("(If({0} Is Nothing, ""None"", {0}.{1}{2}))", propertyExpression, chosenSubproperty.Name, toStringSuffix)
+ End If
+ End If
+ Return "Html.DisplayTextFor(Function(model) " & propertyExpression & ").ToString()"
+End Function
+
+' Helper
+Private Function GetEligibleProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As New List(Of ModelProperty)
+
+ If type IsNot Nothing Then
+ For Each prop As CodeProperty In type.VisibleMembers().OfType(Of CodeProperty)()
+ Dim propValue = prop
+ If (prop.IsReadable() AndAlso (Not prop.HasIndexParameters()) AndAlso (includeUnbindableProperties OrElse IsBindableType(prop.Type))) Then
+ results.Add(New ModelProperty() With { _
+ .Name = prop.Name, _
+ .ValueExpression = ("Model." & prop.Name), _
+ .Type = prop.Type, _
+ .IsPrimaryKey = Model.PrimaryKeyName = prop.Name, _
+ .IsReadOnly = Not prop.IsWriteable(), _
+ .IsForeignKey = ParentRelations.Any(Function(x) propValue.Name = x.RelationProperty.Name) _
+ })
+ End If
+ Next
+ End If
+
+ Return results
+End Function
+
+Private ReadOnly Property ParentRelations As IEnumerable(Of RelatedEntityInfo)
+ Get
+ Return CType(Model.RelatedEntities, IEnumerable).OfType(Of RelatedEntityInfo)().Where(Function(x) x.RelationType = RelationType.Parent)
+ End Get
+End Property
+
+' Helper
+Private Function IsBindableType(ByVal type As CodeTypeRef) As Boolean
+ Return type.UnderlyingIsPrimitive() OrElse bindableNonPrimitiveTypes.Any(Function(x) type.UnderlyingTypeIs(x))
+End Function
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Details.cs.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Details.cs.t4
new file mode 100644
index 0000000..c90ce29
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Details.cs.t4
@@ -0,0 +1,202 @@
+<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="aspx" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<# var viewDataType = (EnvDTE.CodeType) Model.ViewDataType; #>
+<#
+string mvcViewDataTypeGenericString = (viewDataType != null) ? "<" + viewDataType.FullName + ">" : "";
+int CPHCounter = 1;
+#>
+<#
+if(Model.IsContentPage) {
+#>
+<%@ Page Title="" Language="C#" MasterPageFile="~<#= Model.Layout #>" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+<#
+ foreach(string cphid in Model.SectionNames) {
+ if(cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase)) {
+#>
+
+ <#= Model.ViewName #>
+
+
+<#
+ CPHCounter++;
+ }
+ }
+#>
+
+
+
+<# If Not String.IsNullOrEmpty(Model.PrimaryKeyName) Then #>
+ <%: Html.ActionLink("Edit", "Edit", New With {.id = Model.<#= Model.PrimaryKeyName #>}) %> |
+ <%: Html.ActionLink("Back to List", "Index") %>
+<#
+Else
+#>
+ <%--<%: Html.ActionLink("Edit", "Edit", New With {.id = Model.PrimaryKey}) %> |--%>
+ <%: Html.ActionLink("Back to List", "Index") %>
+<#
+End If
+#>
+
+<#
+' 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 Model.IsContentPage
+#>
+
+
+<#
+ For Each cphid As String In Model.SectionNames
+ If String.Compare(cphid, "TitleContent", StringComparison.OrdinalIgnoreCase) <> 0 AndAlso String.Compare(cphid, Model.PrimarySectionName, StringComparison.OrdinalIgnoreCase) <> 0 Then
+ CPHCounter +=1
+#>
+
+
+
+<#
+ End If
+ Next
+#>
+<#
+Else If Not Model.IsContentPage Then
+ ClearIndent()
+#>
+
+
+<#
+End If
+#>
+
+<#+
+' Describes the information about a property on the model
+Private Class ModelProperty
+ Public Name As String
+ Public ValueExpression As String
+ Public Type As CodeTypeRef
+ Public IsReadOnly As Boolean
+ Public IsPrimaryKey As Boolean
+ Public IsForeignKey As Boolean
+End Class
+
+' Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+Private Shared bindableNonPrimitiveTypes As Type() = New Type() {
+ GetType(String),
+ GetType(Decimal),
+ GetType(Guid),
+ GetType(DateTime),
+ GetType(DateTimeOffset),
+ GetType(TimeSpan)
+}
+
+' Call this to get the list of properties in the model. Change this to modify or add your
+' own default formatting for display values.
+Private Function GetModelProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As List(Of ModelProperty) = GetEligibleProperties(type, includeUnbindableProperties)
+
+ For Each modelProp As ModelProperty In results
+ If ((modelProp.Type.UnderlyingTypeIs(GetType(Double))) OrElse (modelProp.Type.UnderlyingTypeIs(GetType(Decimal)))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:F}"", " & modelProp.ValueExpression & ")")
+ ElseIf (modelProp.Type.UnderlyingTypeIs(GetType(DateTime))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:g}"", " & modelProp.ValueExpression & ")")
+ ElseIf (Not IsBindableType(modelProp.Type))
+ modelProp.ValueExpression = GetValueExpression("Model." & modelProp.Name, CType(modelProp.Type.CodeType, CodeType))
+ End If
+ Next
+
+ Return results
+End Function
+
+' Change this list to include the names of properties that should be selected to represent an entity as a single string
+Private Shared displayPropertyNames As String() = New String() { "Name", "Title", "LastName", "Surname", "Subject", "Count" }
+
+Private Function GetValueExpression(ByVal propertyExpression As String, ByVal propertyType As CodeType) As String
+ If propertyType IsNot Nothing Then
+ Dim chosenSubproperty = If(propertyType.DisplayColumnProperty(), propertyType.FindProperty(displayPropertyNames))
+ If chosenSubproperty IsNot Nothing Then
+ Dim toStringSuffix = If(chosenSubproperty.Type.AsFullName = "System.String", "", ".ToString()")
+ Return String.Format("(If({0} Is Nothing, ""None"", {0}.{1}{2}))", propertyExpression, chosenSubproperty.Name, toStringSuffix)
+ End If
+ End If
+ Return "Html.DisplayTextFor(Function(model) " & propertyExpression & ").ToString()"
+End Function
+
+' Helper
+Private Function GetEligibleProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As New List(Of ModelProperty)
+
+ If type IsNot Nothing Then
+ For Each prop As CodeProperty In type.VisibleMembers().OfType(Of CodeProperty)()
+ Dim propValue = prop
+ If (prop.IsReadable() AndAlso (Not prop.HasIndexParameters()) AndAlso (includeUnbindableProperties OrElse IsBindableType(prop.Type))) Then
+ results.Add(New ModelProperty() With { _
+ .Name = prop.Name, _
+ .ValueExpression = ("Model." & prop.Name), _
+ .Type = prop.Type, _
+ .IsPrimaryKey = Model.PrimaryKeyName = prop.Name, _
+ .IsReadOnly = Not prop.IsWriteable(), _
+ .IsForeignKey = ParentRelations.Any(Function(x) propValue.Name = x.RelationProperty.Name) _
+ })
+ End If
+ Next
+ End If
+
+ Return results
+End Function
+
+Private ReadOnly Property ParentRelations As IEnumerable(Of RelatedEntityInfo)
+ Get
+ Return CType(Model.RelatedEntities, IEnumerable).OfType(Of RelatedEntityInfo)().Where(Function(x) x.RelationType = RelationType.Parent)
+ End Get
+End Property
+
+' Helper
+Private Function IsBindableType(ByVal type As CodeTypeRef) As Boolean
+ Return type.UnderlyingIsPrimitive() OrElse bindableNonPrimitiveTypes.Any(Function(x) type.UnderlyingTypeIs(x))
+End Function
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Edit.cs.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Edit.cs.t4
new file mode 100644
index 0000000..897cb36
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Edit.cs.t4
@@ -0,0 +1,198 @@
+<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="aspx" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<# var viewDataType = (EnvDTE.CodeType) Model.ViewDataType; #>
+<#
+string mvcViewDataTypeGenericString = (viewDataType != null) ? "<" + viewDataType.FullName + ">" : "";
+int CPHCounter = 1;
+#>
+<#
+if(Model.IsContentPage) {
+#>
+<%@ Page Title="" Language="C#" MasterPageFile="~<#= Model.Layout #>" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+<#
+ foreach(string cphid in Model.SectionNames) {
+ if(cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase)) {
+#>
+
+ <#= Model.ViewName #>
+
+
+<#
+ CPHCounter++;
+ }
+ }
+#>
+
+
+
+ <%: Html.ActionLink("Back to List", "Index") %>
+
+<#
+// 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(Model.IsContentPage) {
+#>
+
+
+<#
+ foreach(string cphid in Model.SectionNames) {
+ if(!cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase) && !cphid.Equals(Model.PrimarySectionName, StringComparison.OrdinalIgnoreCase)) {
+ CPHCounter++;
+#>
+
+
+
+<#
+ }
+ }
+#>
+<#
+} else if(!Model.IsContentPage) {
+ ClearIndent();
+#>
+
+
+<#
+}
+#>
+
+
+<#+
+// Describes the information about a property on the model
+class ModelProperty {
+ public string Name { get; set; }
+ public string ValueExpression { get; set; }
+ public EnvDTE.CodeTypeRef Type { get; set; }
+ public bool IsPrimaryKey { get; set; }
+ public bool IsForeignKey { get; set; }
+ public bool IsReadOnly { get; set; }
+}
+
+// Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+static Type[] bindableNonPrimitiveTypes = new[] {
+ typeof(string),
+ typeof(decimal),
+ typeof(Guid),
+ typeof(DateTime),
+ typeof(DateTimeOffset),
+ typeof(TimeSpan),
+};
+
+// 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(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = GetEligibleProperties(typeInfo, includeUnbindableProperties);
+
+ foreach (ModelProperty prop in results) {
+ if (prop.Type.UnderlyingTypeIs() || prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:F}\", " + prop.ValueExpression + ")";
+ }
+ else if (prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:g}\", " + prop.ValueExpression + ")";
+ }
+ else if (!IsBindableType(prop.Type)) {
+ prop.ValueExpression = GetValueExpression("Model." + prop.Name, (EnvDTE.CodeType)prop.Type.CodeType);
+ }
+ }
+
+ return results;
+}
+
+// Change this list to include the names of properties that should be selected to represent an entity as a single string
+static string[] displayPropertyNames = new[] { "Name", "Title", "LastName", "Surname", "Subject", "Count" };
+
+string GetValueExpression(string propertyExpression, EnvDTE.CodeType propertyType) {
+ if (propertyType != null) {
+ var chosenSubproperty = propertyType.DisplayColumnProperty() ?? propertyType.FindProperty(displayPropertyNames);
+ if (chosenSubproperty != null) {
+ var toStringSuffix = chosenSubproperty.Type.AsFullName == "System.String" ? "" : ".ToString()";
+ return String.Format("({0} == null ? \"None\" : {0}.{1}{2})", propertyExpression, chosenSubproperty.Name, toStringSuffix);
+ }
+ }
+ return "Html.DisplayTextFor(_ => " + propertyExpression + ").ToString()";
+}
+
+// Helper
+List GetEligibleProperties(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = new List();
+ if (typeInfo != null) {
+ foreach (var prop in typeInfo.VisibleMembers().OfType()) {
+ if (prop.IsReadable() && !prop.HasIndexParameters() && (includeUnbindableProperties || IsBindableType(prop.Type))) {
+ results.Add(new ModelProperty {
+ Name = prop.Name,
+ ValueExpression = "Model." + prop.Name,
+ Type = prop.Type,
+ IsPrimaryKey = Model.PrimaryKeyName == prop.Name,
+ IsForeignKey = ParentRelations.Any(x => x.RelationProperty == prop),
+ IsReadOnly = !prop.IsWriteable()
+ });
+ }
+ }
+ }
+
+ return results;
+}
+
+IEnumerable ParentRelations {
+ get { return ((IEnumerable)Model.RelatedEntities).OfType().Where(x => x.RelationType == RelationType.Parent); }
+}
+
+// Helper
+bool IsBindableType(EnvDTE.CodeTypeRef type) {
+ return type.UnderlyingIsPrimitive() || bindableNonPrimitiveTypes.Any(x => type.UnderlyingTypeIs(x));
+}
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Edit.vb.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Edit.vb.t4
new file mode 100644
index 0000000..358b15f
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Edit.vb.t4
@@ -0,0 +1,203 @@
+<#@ Template Language="VB" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="aspx" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<#@ import namespace="EnvDTE" #>
+<#
+Dim viewDataType = CType(Model.ViewDataType, CodeType)
+Dim mvcViewDataTypeGenericString As String = If(viewDataType IsNot Nothing, "(Of " & viewDataType.FullName & ")", String.Empty)
+Dim CPHCounter As Integer = 1
+#>
+<#
+If Model.IsContentPage Then
+#>
+<%@ Page Title="" Language="VB" MasterPageFile="~<#= Model.Layout #>" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+<#
+ For Each cphid As String In Model.SectionNames
+ If cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase) Then
+#>
+
+ <#= Model.ViewName #>
+
+
+<#
+ CPHCounter += 1
+ End If
+ Next
+#>
+
+
+
<#= Model.ViewName #>
+
+<#
+Else
+#>
+<%@ Page Language="VB" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+
+
+
+ <#= Model.ViewName #>
+
+
+<#
+ PushIndent(" ")
+End If
+#>
+<%-- The following line works around an ASP.NET compiler warning --%>
+<%: "" %>
+
+<# If Model.ReferenceScriptLibraries Then #>
+<# If Not Model.IsContentPage Then #>
+
+<# End If #>
+
+
+
+<# End If #>
+<% Using Html.BeginForm() %>
+ <%: Html.ValidationSummary(True) %>
+
+<% End Using %>
+
+
+ <%: Html.ActionLink("Back to List", "Index") %>
+
+<#
+' 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 Model.IsContentPage
+#>
+
+
+<#
+ For Each cphid As String In Model.SectionNames
+ If String.Compare(cphid, "TitleContent", StringComparison.OrdinalIgnoreCase) <> 0 AndAlso String.Compare(cphid, Model.PrimarySectionName, StringComparison.OrdinalIgnoreCase) <> 0 Then
+ CPHCounter +=1
+#>
+
+
+
+<#
+ End If
+ Next
+#>
+<#
+Else If Not Model.IsContentPage Then
+ ClearIndent()
+#>
+
+
+<#
+End If
+#>
+
+<#+
+' Describes the information about a property on the model
+Private Class ModelProperty
+ Public Name As String
+ Public ValueExpression As String
+ Public Type As CodeTypeRef
+ Public IsReadOnly As Boolean
+ Public IsPrimaryKey As Boolean
+ Public IsForeignKey As Boolean
+End Class
+
+' Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+Private Shared bindableNonPrimitiveTypes As Type() = New Type() {
+ GetType(String),
+ GetType(Decimal),
+ GetType(Guid),
+ GetType(DateTime),
+ GetType(DateTimeOffset),
+ GetType(TimeSpan)
+}
+
+' Call this to get the list of properties in the model. Change this to modify or add your
+' own default formatting for display values.
+Private Function GetModelProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As List(Of ModelProperty) = GetEligibleProperties(type, includeUnbindableProperties)
+
+ For Each modelProp As ModelProperty In results
+ If ((modelProp.Type.UnderlyingTypeIs(GetType(Double))) OrElse (modelProp.Type.UnderlyingTypeIs(GetType(Decimal)))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:F}"", " & modelProp.ValueExpression & ")")
+ ElseIf (modelProp.Type.UnderlyingTypeIs(GetType(DateTime))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:g}"", " & modelProp.ValueExpression & ")")
+ ElseIf (Not IsBindableType(modelProp.Type))
+ modelProp.ValueExpression = GetValueExpression("Model." & modelProp.Name, CType(modelProp.Type.CodeType, CodeType))
+ End If
+ Next
+
+ Return results
+End Function
+
+' Change this list to include the names of properties that should be selected to represent an entity as a single string
+Private Shared displayPropertyNames As String() = New String() { "Name", "Title", "LastName", "Surname", "Subject", "Count" }
+
+Private Function GetValueExpression(ByVal propertyExpression As String, ByVal propertyType As CodeType) As String
+ If propertyType IsNot Nothing Then
+ Dim chosenSubproperty = If(propertyType.DisplayColumnProperty(), propertyType.FindProperty(displayPropertyNames))
+ If chosenSubproperty IsNot Nothing Then
+ Dim toStringSuffix = If(chosenSubproperty.Type.AsFullName = "System.String", "", ".ToString()")
+ Return String.Format("(If({0} Is Nothing, ""None"", {0}.{1}{2}))", propertyExpression, chosenSubproperty.Name, toStringSuffix)
+ End If
+ End If
+ Return "Html.DisplayTextFor(Function(model) " & propertyExpression & ").ToString()"
+End Function
+
+' Helper
+Private Function GetEligibleProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As New List(Of ModelProperty)
+
+ If type IsNot Nothing Then
+ For Each prop As CodeProperty In type.VisibleMembers().OfType(Of CodeProperty)()
+ Dim propValue = prop
+ If (prop.IsReadable() AndAlso (Not prop.HasIndexParameters()) AndAlso (includeUnbindableProperties OrElse IsBindableType(prop.Type))) Then
+ results.Add(New ModelProperty() With { _
+ .Name = prop.Name, _
+ .ValueExpression = ("Model." & prop.Name), _
+ .Type = prop.Type, _
+ .IsPrimaryKey = Model.PrimaryKeyName = prop.Name, _
+ .IsReadOnly = Not prop.IsWriteable(), _
+ .IsForeignKey = ParentRelations.Any(Function(x) propValue.Name = x.RelationProperty.Name) _
+ })
+ End If
+ Next
+ End If
+
+ Return results
+End Function
+
+Private ReadOnly Property ParentRelations As IEnumerable(Of RelatedEntityInfo)
+ Get
+ Return CType(Model.RelatedEntities, IEnumerable).OfType(Of RelatedEntityInfo)().Where(Function(x) x.RelationType = RelationType.Parent)
+ End Get
+End Property
+
+' Helper
+Private Function IsBindableType(ByVal type As CodeTypeRef) As Boolean
+ Return type.UnderlyingIsPrimitive() OrElse bindableNonPrimitiveTypes.Any(Function(x) type.UnderlyingTypeIs(x))
+End Function
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Empty.cs.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Empty.cs.t4
new file mode 100644
index 0000000..cb94784
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Empty.cs.t4
@@ -0,0 +1,79 @@
+<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="aspx" #>
+<# var viewDataType = (EnvDTE.CodeType) Model.ViewDataType; #>
+<#
+string mvcViewDataTypeGenericString = (viewDataType != null) ? "<" + viewDataType.FullName + ">" : "";
+int CPHCounter = 1;
+#>
+<# if(Model.IsContentPage) { #>
+<%@ Page Title="" Language="C#" MasterPageFile="~<#= Model.Layout #>" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+<#
+ foreach(string cphid in Model.SectionNames) {
+ if(cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase)) {
+#>
+
+ <#= Model.ViewName #>
+
+
+<#
+ CPHCounter++;
+ }
+ }
+#>
+
+
+
+<#
+}
+#>
+<#
+// 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(Model.IsContentPage) {
+#>
+
+<#
+ foreach(string cphid in Model.SectionNames) {
+ if(!cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase) && !cphid.Equals(Model.PrimarySectionName, StringComparison.OrdinalIgnoreCase)) {
+ CPHCounter++;
+#>
+
+
+
+<#
+ }
+ }
+#>
+<#
+} else if(!Model.IsContentPage) {
+ ClearIndent();
+#>
+
+
+<#
+}
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Empty.vb.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Empty.vb.t4
new file mode 100644
index 0000000..e9abe8c
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/AspxView/Empty.vb.t4
@@ -0,0 +1,81 @@
+<#@ Template Language="VB" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="aspx" #>
+<#
+Dim viewDataType = CType(Model.ViewDataType, EnvDTE.CodeType)
+Dim mvcViewDataTypeGenericString As String = If(viewDataType IsNot Nothing, "(Of " & viewDataType.FullName & ")", String.Empty)
+Dim CPHCounter As Integer = 1
+#>
+<#
+If Model.IsContentPage Then
+#>
+<%@ Page Title="" Language="VB" MasterPageFile="~<#= Model.Layout #>" Inherits="System.Web.Mvc.ViewPage<#= mvcViewDataTypeGenericString #>" %>
+
+<#
+ For Each cphid As String In Model.SectionNames
+ If cphid.Equals("TitleContent", StringComparison.OrdinalIgnoreCase) Then
+#>
+
+ <#= Model.ViewName #>
+
+
+<#
+ CPHCounter += 1
+ End If
+ Next
+#>
+
+
+
+<#
+Dim properties As List(Of ModelProperty) = GetModelProperties(Model.ViewDataType, True)
+For Each modelProp As ModelProperty In properties
+ If (Not modelProp.IsPrimaryKey AndAlso Not modelProp.IsForeignKey) Then
+#>
+
+ <#= modelProp.Name #>
+
+<#
+ End If
+Next
+#>
+
+
+<% For Each item In Model %>
+ <% Dim itemValue = item %>
+
+<# If Not String.IsNullOrEmpty(Model.PrimaryKeyName) Then #>
+
+ <%: Html.ActionLink("Edit", "Edit", New With {.id = itemValue.<#= Model.PrimaryKeyName #>}) %> |
+ <%: Html.ActionLink("Details", "Details", New With {.id = itemValue.<#= Model.PrimaryKeyName #>}) %> |
+ <%: Html.ActionLink("Delete", "Delete", New With {.id = itemValue.<#= Model.PrimaryKeyName #>}) %>
+
+<#
+Else
+#>
+
+ <%--<%: Html.ActionLink("Edit", "Edit", New With {.id = itemValue.PrimaryKey}) %> |
+ <%: Html.ActionLink("Details", "Details", New With {.id = itemValue.PrimaryKey}) %> |
+ <%: Html.ActionLink("Delete", "Delete", New With {.id = itemValue.PrimaryKey}) %>--%>
+
+<#
+End If
+
+For Each modelProp As ModelProperty In properties
+ If (Not modelProp.IsPrimaryKey AndAlso Not modelProp.IsForeignKey) Then
+#>
+
+
+
+<#+
+// Describes the information about a property on the model
+class ModelProperty {
+ public string Name { get; set; }
+ public string ValueExpression { get; set; }
+ public EnvDTE.CodeTypeRef Type { get; set; }
+ public bool IsPrimaryKey { get; set; }
+ public bool IsForeignKey { get; set; }
+ public bool IsReadOnly { get; set; }
+}
+
+// Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+static Type[] bindableNonPrimitiveTypes = new[] {
+ typeof(string),
+ typeof(decimal),
+ typeof(Guid),
+ typeof(DateTime),
+ typeof(DateTimeOffset),
+ typeof(TimeSpan),
+};
+
+// 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(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = GetEligibleProperties(typeInfo, includeUnbindableProperties);
+
+ foreach (ModelProperty prop in results) {
+ if (prop.Type.UnderlyingTypeIs() || prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:F}\", " + prop.ValueExpression + ")";
+ }
+ else if (prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:g}\", " + prop.ValueExpression + ")";
+ }
+ else if (!IsBindableType(prop.Type)) {
+ prop.ValueExpression = GetValueExpression("Model." + prop.Name, (EnvDTE.CodeType)prop.Type.CodeType);
+ }
+ }
+
+ return results;
+}
+
+// Change this list to include the names of properties that should be selected to represent an entity as a single string
+static string[] displayPropertyNames = new[] { "Name", "Title", "LastName", "Surname", "Subject", "Count" };
+
+string GetValueExpression(string propertyExpression, EnvDTE.CodeType propertyType) {
+ if (propertyType != null) {
+ var chosenSubproperty = propertyType.DisplayColumnProperty() ?? propertyType.FindProperty(displayPropertyNames);
+ if (chosenSubproperty != null) {
+ var toStringSuffix = chosenSubproperty.Type.AsFullName == "System.String" ? "" : ".ToString()";
+ return String.Format("({0} == null ? \"None\" : {0}.{1}{2})", propertyExpression, chosenSubproperty.Name, toStringSuffix);
+ }
+ }
+ return "Html.DisplayTextFor(_ => " + propertyExpression + ").ToString()";
+}
+
+// Helper
+List GetEligibleProperties(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = new List();
+ if (typeInfo != null) {
+ foreach (var prop in typeInfo.VisibleMembers().OfType()) {
+ if (prop.IsReadable() && !prop.HasIndexParameters() && (includeUnbindableProperties || IsBindableType(prop.Type))) {
+ results.Add(new ModelProperty {
+ Name = prop.Name,
+ ValueExpression = "Model." + prop.Name,
+ Type = prop.Type,
+ IsPrimaryKey = Model.PrimaryKeyName == prop.Name,
+ IsForeignKey = ParentRelations.Any(x => x.RelationProperty == prop),
+ IsReadOnly = !prop.IsWriteable()
+ });
+ }
+ }
+ }
+
+ return results;
+}
+
+IEnumerable ParentRelations {
+ get { return ((IEnumerable)Model.RelatedEntities).OfType().Where(x => x.RelationType == RelationType.Parent); }
+}
+
+// Helper
+bool IsBindableType(EnvDTE.CodeTypeRef type) {
+ return type.UnderlyingIsPrimitive() || bindableNonPrimitiveTypes.Any(x => type.UnderlyingTypeIs(x));
+}
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Create.vb.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Create.vb.t4
new file mode 100644
index 0000000..f89970b
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Create.vb.t4
@@ -0,0 +1,137 @@
+<#@ Template Language="VB" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="vbhtml" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<#@ import namespace="EnvDTE" #>
+<# Dim viewDataType = CType(Model.ViewDataType, CodeType) #>
+<# If viewDataType IsNot Nothing #>
+@ModelType <#= viewDataType.FullName #>
+
+<# End If #>
+@Code
+ ViewData("Title") = "<#= Model.ViewName #>"
+<# If Not String.IsNullOrEmpty(Model.Layout) #>
+ Layout = "<#= Model.Layout #>"
+<# End If #>
+End Code
+
+
<#= Model.ViewName #>
+
+<# If Model.ReferenceScriptLibraries Then #>
+
+
+
+<# End If #>
+@Using Html.BeginForm()
+ @Html.ValidationSummary(True)
+ @
+End Using
+
+
+ @Html.ActionLink("Back to List", "Index")
+
+
+<#+
+' Describes the information about a property on the model
+Private Class ModelProperty
+ Public Name As String
+ Public ValueExpression As String
+ Public Type As CodeTypeRef
+ Public IsReadOnly As Boolean
+ Public IsPrimaryKey As Boolean
+ Public IsForeignKey As Boolean
+End Class
+
+' Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+Private Shared bindableNonPrimitiveTypes As Type() = New Type() {
+ GetType(String),
+ GetType(Decimal),
+ GetType(Guid),
+ GetType(DateTime),
+ GetType(DateTimeOffset),
+ GetType(TimeSpan)
+}
+
+' Call this to get the list of properties in the model. Change this to modify or add your
+' own default formatting for display values.
+Private Function GetModelProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As List(Of ModelProperty) = GetEligibleProperties(type, includeUnbindableProperties)
+
+ For Each modelProp As ModelProperty In results
+ If ((modelProp.Type.UnderlyingTypeIs(GetType(Double))) OrElse (modelProp.Type.UnderlyingTypeIs(GetType(Decimal)))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:F}"", " & modelProp.ValueExpression & ")")
+ ElseIf (modelProp.Type.UnderlyingTypeIs(GetType(DateTime))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:g}"", " & modelProp.ValueExpression & ")")
+ ElseIf (Not IsBindableType(modelProp.Type))
+ modelProp.ValueExpression = GetValueExpression("Model." & modelProp.Name, CType(modelProp.Type.CodeType, CodeType))
+ End If
+ Next
+
+ Return results
+End Function
+
+' Change this list to include the names of properties that should be selected to represent an entity as a single string
+Private Shared displayPropertyNames As String() = New String() { "Name", "Title", "LastName", "Surname", "Subject", "Count" }
+
+Private Function GetValueExpression(ByVal propertyExpression As String, ByVal propertyType As CodeType) As String
+ If propertyType IsNot Nothing Then
+ Dim chosenSubproperty = If(propertyType.DisplayColumnProperty(), propertyType.FindProperty(displayPropertyNames))
+ If chosenSubproperty IsNot Nothing Then
+ Dim toStringSuffix = If(chosenSubproperty.Type.AsFullName = "System.String", "", ".ToString()")
+ Return String.Format("(If({0} Is Nothing, ""None"", {0}.{1}{2}))", propertyExpression, chosenSubproperty.Name, toStringSuffix)
+ End If
+ End If
+ Return "Html.DisplayTextFor(Function(model) " & propertyExpression & ").ToString()"
+End Function
+
+' Helper
+Private Function GetEligibleProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As New List(Of ModelProperty)
+
+ If type IsNot Nothing Then
+ For Each prop As CodeProperty In type.VisibleMembers().OfType(Of CodeProperty)()
+ Dim propValue = prop
+ If (prop.IsReadable() AndAlso (Not prop.HasIndexParameters()) AndAlso (includeUnbindableProperties OrElse IsBindableType(prop.Type))) Then
+ results.Add(New ModelProperty() With { _
+ .Name = prop.Name, _
+ .ValueExpression = ("Model." & prop.Name), _
+ .Type = prop.Type, _
+ .IsPrimaryKey = Model.PrimaryKeyName = prop.Name, _
+ .IsReadOnly = Not prop.IsWriteable(), _
+ .IsForeignKey = ParentRelations.Any(Function(x) propValue.Name = x.RelationProperty.Name) _
+ })
+ End If
+ Next
+ End If
+
+ Return results
+End Function
+
+Private ReadOnly Property ParentRelations As IEnumerable(Of RelatedEntityInfo)
+ Get
+ Return CType(Model.RelatedEntities, IEnumerable).OfType(Of RelatedEntityInfo)().Where(Function(x) x.RelationType = RelationType.Parent)
+ End Get
+End Property
+
+' Helper
+Private Function IsBindableType(ByVal type As CodeTypeRef) As Boolean
+ Return type.UnderlyingIsPrimitive() OrElse bindableNonPrimitiveTypes.Any(Function(x) type.UnderlyingTypeIs(x))
+End Function
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Delete.cs.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Delete.cs.t4
new file mode 100644
index 0000000..161e472
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Delete.cs.t4
@@ -0,0 +1,136 @@
+<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="cshtml" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<# var viewDataType = (EnvDTE.CodeType) Model.ViewDataType; #>
+<# if(viewDataType != null) { #>
+@model <#= viewDataType.FullName #>
+
+<# } #>
+@{
+ ViewBag.Title = "<#= Model.ViewName #>";
+<# if (!String.IsNullOrEmpty(Model.Layout)) { #>
+ Layout = "<#= Model.Layout #>";
+<# } #>
+}
+
+
<#= Model.ViewName #>
+
+
Are you sure you want to delete this?
+
+@using (Html.BeginForm()) {
+
+ |
+ @Html.ActionLink("Back to List", "Index")
+
+}
+
+
+<#+
+// Describes the information about a property on the model
+class ModelProperty {
+ public string Name { get; set; }
+ public string ValueExpression { get; set; }
+ public EnvDTE.CodeTypeRef Type { get; set; }
+ public bool IsPrimaryKey { get; set; }
+ public bool IsForeignKey { get; set; }
+ public bool IsReadOnly { get; set; }
+}
+
+// Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+static Type[] bindableNonPrimitiveTypes = new[] {
+ typeof(string),
+ typeof(decimal),
+ typeof(Guid),
+ typeof(DateTime),
+ typeof(DateTimeOffset),
+ typeof(TimeSpan),
+};
+
+// 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(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = GetEligibleProperties(typeInfo, includeUnbindableProperties);
+
+ foreach (ModelProperty prop in results) {
+ if (prop.Type.UnderlyingTypeIs() || prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:F}\", " + prop.ValueExpression + ")";
+ }
+ else if (prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:g}\", " + prop.ValueExpression + ")";
+ }
+ else if (!IsBindableType(prop.Type)) {
+ prop.ValueExpression = GetValueExpression("Model." + prop.Name, (EnvDTE.CodeType)prop.Type.CodeType);
+ }
+ }
+
+ return results;
+}
+
+// Change this list to include the names of properties that should be selected to represent an entity as a single string
+static string[] displayPropertyNames = new[] { "Name", "Title", "LastName", "Surname", "Subject", "Count" };
+
+string GetValueExpression(string propertyExpression, EnvDTE.CodeType propertyType) {
+ if (propertyType != null) {
+ var chosenSubproperty = propertyType.DisplayColumnProperty() ?? propertyType.FindProperty(displayPropertyNames);
+ if (chosenSubproperty != null) {
+ var toStringSuffix = chosenSubproperty.Type.AsFullName == "System.String" ? "" : ".ToString()";
+ return String.Format("({0} == null ? \"None\" : {0}.{1}{2})", propertyExpression, chosenSubproperty.Name, toStringSuffix);
+ }
+ }
+ return "Html.DisplayTextFor(_ => " + propertyExpression + ").ToString()";
+}
+
+// Helper
+List GetEligibleProperties(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = new List();
+ if (typeInfo != null) {
+ foreach (var prop in typeInfo.VisibleMembers().OfType()) {
+ if (prop.IsReadable() && !prop.HasIndexParameters() && (includeUnbindableProperties || IsBindableType(prop.Type))) {
+ results.Add(new ModelProperty {
+ Name = prop.Name,
+ ValueExpression = "Model." + prop.Name,
+ Type = prop.Type,
+ IsPrimaryKey = Model.PrimaryKeyName == prop.Name,
+ IsForeignKey = ParentRelations.Any(x => x.RelationProperty == prop),
+ IsReadOnly = !prop.IsWriteable()
+ });
+ }
+ }
+ }
+
+ return results;
+}
+
+IEnumerable ParentRelations {
+ get { return ((IEnumerable)Model.RelatedEntities).OfType().Where(x => x.RelationType == RelationType.Parent); }
+}
+
+// Helper
+bool IsBindableType(EnvDTE.CodeTypeRef type) {
+ return type.UnderlyingIsPrimitive() || bindableNonPrimitiveTypes.Any(x => type.UnderlyingTypeIs(x));
+}
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Delete.vb.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Delete.vb.t4
new file mode 100644
index 0000000..c808ab5
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Delete.vb.t4
@@ -0,0 +1,139 @@
+<#@ Template Language="VB" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="vbhtml" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<#@ import namespace="EnvDTE" #>
+<# Dim viewDataType = CType(Model.ViewDataType, CodeType) #>
+<# If viewDataType IsNot Nothing #>
+@ModelType <#= viewDataType.FullName #>
+
+<# End If #>
+@Code
+ ViewData("Title") = "<#= Model.ViewName #>"
+<# If Not String.IsNullOrEmpty(Model.Layout) #>
+ Layout = "<#= Model.Layout #>"
+<# End If #>
+End Code
+
+
<#= Model.ViewName #>
+
+
Are you sure you want to delete this?
+
+
+@Using Html.BeginForm()
+ @
+ |
+ @Html.ActionLink("Back to List", "Index")
+
+End Using
+
+<#+
+' Describes the information about a property on the model
+Private Class ModelProperty
+ Public Name As String
+ Public ValueExpression As String
+ Public Type As CodeTypeRef
+ Public IsReadOnly As Boolean
+ Public IsPrimaryKey As Boolean
+ Public IsForeignKey As Boolean
+End Class
+
+' Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+Private Shared bindableNonPrimitiveTypes As Type() = New Type() {
+ GetType(String),
+ GetType(Decimal),
+ GetType(Guid),
+ GetType(DateTime),
+ GetType(DateTimeOffset),
+ GetType(TimeSpan)
+}
+
+' Call this to get the list of properties in the model. Change this to modify or add your
+' own default formatting for display values.
+Private Function GetModelProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As List(Of ModelProperty) = GetEligibleProperties(type, includeUnbindableProperties)
+
+ For Each modelProp As ModelProperty In results
+ If ((modelProp.Type.UnderlyingTypeIs(GetType(Double))) OrElse (modelProp.Type.UnderlyingTypeIs(GetType(Decimal)))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:F}"", " & modelProp.ValueExpression & ")")
+ ElseIf (modelProp.Type.UnderlyingTypeIs(GetType(DateTime))) Then
+ modelProp.ValueExpression = ("String.Format(""{0:g}"", " & modelProp.ValueExpression & ")")
+ ElseIf (Not IsBindableType(modelProp.Type))
+ modelProp.ValueExpression = GetValueExpression("Model." & modelProp.Name, CType(modelProp.Type.CodeType, CodeType))
+ End If
+ Next
+
+ Return results
+End Function
+
+' Change this list to include the names of properties that should be selected to represent an entity as a single string
+Private Shared displayPropertyNames As String() = New String() { "Name", "Title", "LastName", "Surname", "Subject", "Count" }
+
+Private Function GetValueExpression(ByVal propertyExpression As String, ByVal propertyType As CodeType) As String
+ If propertyType IsNot Nothing Then
+ Dim chosenSubproperty = If(propertyType.DisplayColumnProperty(), propertyType.FindProperty(displayPropertyNames))
+ If chosenSubproperty IsNot Nothing Then
+ Dim toStringSuffix = If(chosenSubproperty.Type.AsFullName = "System.String", "", ".ToString()")
+ Return String.Format("(If({0} Is Nothing, ""None"", {0}.{1}{2}))", propertyExpression, chosenSubproperty.Name, toStringSuffix)
+ End If
+ End If
+ Return "Html.DisplayTextFor(Function(model) " & propertyExpression & ").ToString()"
+End Function
+
+' Helper
+Private Function GetEligibleProperties(ByVal type As CodeType, ByVal includeUnbindableProperties As Boolean) As List(Of ModelProperty)
+ Dim results As New List(Of ModelProperty)
+
+ If type IsNot Nothing Then
+ For Each prop As CodeProperty In type.VisibleMembers().OfType(Of CodeProperty)()
+ Dim propValue = prop
+ If (prop.IsReadable() AndAlso (Not prop.HasIndexParameters()) AndAlso (includeUnbindableProperties OrElse IsBindableType(prop.Type))) Then
+ results.Add(New ModelProperty() With { _
+ .Name = prop.Name, _
+ .ValueExpression = ("Model." & prop.Name), _
+ .Type = prop.Type, _
+ .IsPrimaryKey = Model.PrimaryKeyName = prop.Name, _
+ .IsReadOnly = Not prop.IsWriteable(), _
+ .IsForeignKey = ParentRelations.Any(Function(x) propValue.Name = x.RelationProperty.Name) _
+ })
+ End If
+ Next
+ End If
+
+ Return results
+End Function
+
+Private ReadOnly Property ParentRelations As IEnumerable(Of RelatedEntityInfo)
+ Get
+ Return CType(Model.RelatedEntities, IEnumerable).OfType(Of RelatedEntityInfo)().Where(Function(x) x.RelationType = RelationType.Parent)
+ End Get
+End Property
+
+' Helper
+Private Function IsBindableType(ByVal type As CodeTypeRef) As Boolean
+ Return type.UnderlyingIsPrimitive() OrElse bindableNonPrimitiveTypes.Any(Function(x) type.UnderlyingTypeIs(x))
+End Function
+#>
\ No newline at end of file
diff --git a/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Details.cs.t4 b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Details.cs.t4
new file mode 100644
index 0000000..bf4f8af
--- /dev/null
+++ b/CharityPortal/packages/MvcScaffolding.1.0.0/tools/RazorView/Details.cs.t4
@@ -0,0 +1,138 @@
+<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
+<#@ Output extension="cshtml" #>
+<#@ assembly name="System.ComponentModel.DataAnnotations" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="System.Data.Entity" #>
+<#@ assembly name="System.Data.Linq" #>
+<#@ import namespace="System" #>
+<#@ import namespace="System.Collections" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.ComponentModel.DataAnnotations" #>
+<#@ import namespace="System.Data.Linq.Mapping" #>
+<#@ import namespace="System.Data.Objects.DataClasses" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Reflection" #>
+<# var viewDataType = (EnvDTE.CodeType) Model.ViewDataType; #>
+<# if(viewDataType != null) { #>
+@model <#= viewDataType.FullName #>
+
+<# } #>
+@{
+ ViewBag.Title = "<#= Model.ViewName #>";
+<# if (!String.IsNullOrEmpty(Model.Layout)) { #>
+ Layout = "<#= Model.Layout #>";
+<# } #>
+}
+
+
<#= Model.ViewName #>
+
+
+
+<# if (!String.IsNullOrEmpty(Model.PrimaryKeyName)) { #>
+ @Html.ActionLink("Edit", "Edit", new { id=Model.<#= Model.PrimaryKeyName #> }) |
+ @Html.ActionLink("Back to List", "Index")
+<# } else { #>
+ @Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) |
+ @Html.ActionLink("Back to List", "Index")
+<# } #>
+
+
+
+<#+
+// Describes the information about a property on the model
+class ModelProperty {
+ public string Name { get; set; }
+ public string ValueExpression { get; set; }
+ public EnvDTE.CodeTypeRef Type { get; set; }
+ public bool IsPrimaryKey { get; set; }
+ public bool IsForeignKey { get; set; }
+ public bool IsReadOnly { get; set; }
+}
+
+// Change this list to include any non-primitive types you think should be eligible to be edited using a textbox
+static Type[] bindableNonPrimitiveTypes = new[] {
+ typeof(string),
+ typeof(decimal),
+ typeof(Guid),
+ typeof(DateTime),
+ typeof(DateTimeOffset),
+ typeof(TimeSpan),
+};
+
+// 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(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
+ List results = GetEligibleProperties(typeInfo, includeUnbindableProperties);
+
+ foreach (ModelProperty prop in results) {
+ if (prop.Type.UnderlyingTypeIs() || prop.Type.UnderlyingTypeIs()) {
+ prop.ValueExpression = "String.Format(\"{0:F}\", " + prop.ValueExpression + ")";
+ }
+ else if (prop.Type.UnderlyingTypeIs