diff --git a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Create.cshtml b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Create.cshtml new file mode 100644 index 00000000..4cd712a2 --- /dev/null +++ b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Create.cshtml @@ -0,0 +1,145 @@ +@inherits Microsoft.Extensions.CodeGeneration.Templating.RazorTemplateBase +@using Microsoft.Extensions.CodeGeneration.EntityFramework +@@model @Model.ViewDataTypeName + +@{ + if (Model.IsPartialView) + { + } + else if (Model.IsLayoutPageSelected) + { +@:@@{ + @:ViewData["Title"] = @@SR["@Model.ViewName"]; + if (!string.IsNullOrEmpty(Model.LayoutPageFile)) + { + @:Layout = "@Model.LayoutPageFile"; + } +@:} +@: +@:
+@{ + string pkName = GetPrimaryKeyName(); + if (pkName != null) + { + @:@@SR["Edit"] | + @:@@SR["Back to List"] + } + else + { + @:@@Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) | + @:@@SR["Back to List"] + } +}
+@{ + if (!Model.IsPartialView && !Model.IsLayoutPageSelected) + { + //ClearIndent(); +@: +@: + } +} +@functions +{ + string GetPrimaryKeyName() + { + return (Model.ModelMetadata.PrimaryKeys != null && Model.ModelMetadata.PrimaryKeys.Length == 1) + ? Model.ModelMetadata.PrimaryKeys[0].PropertyName + : null; + } + + string GetValueExpression(PropertyMetadata property) + { + //Todo: Get the association for the property and use that. + return property.PropertyName; + } +} \ No newline at end of file diff --git a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Edit.cshtml b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Edit.cshtml new file mode 100644 index 00000000..36316b1e --- /dev/null +++ b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Edit.cshtml @@ -0,0 +1,149 @@ +@inherits Microsoft.Extensions.CodeGeneration.Templating.RazorTemplateBase +@using Microsoft.Extensions.CodeGeneration.EntityFramework +@@model @Model.ViewDataTypeName + +@{ + if (Model.IsPartialView) + { + } + else if (Model.IsLayoutPageSelected) + { +@:@@{ + @:ViewData["Title"] = @@SR["@Model.ViewName"]; + if (!string.IsNullOrEmpty(Model.LayoutPageFile)) + { + @:Layout = "@Model.LayoutPageFile"; + } +@:} +@: +@:+ @:@@SR["Create New"] +@:
+@:+ @@Html.DisplayNameFor(model => model.@GetValueExpression(property)) + | + } + } + @:+ @: | |
---|---|---|
+ @@Html.DisplayFor(modelItem => item.@GetValueExpression(property)) + | + } + } + + string pkName = GetPrimaryKeyName(); + if (pkName != null) + { + @:+ @:@@SR["Edit"] | + @:@@SR["Details"] | + @:@@SR["Delete"] + @: | + } + else + { ++ @@Html.ActionLink("Edit", SR["Edit"], new { /* id=item.PrimaryKey */ }) | + @@Html.ActionLink("Details", SR["Details"], new { /* id=item.PrimaryKey */ }) | + @@Html.ActionLink("Delete", SR["Delete"], new { /* id=item.PrimaryKey */ }) + | + } + @: