1 @inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
2 @using Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore
3 @using System.Collections.Generic
6 @@model @Model.NamespaceName.@Model.PageModelClassName
9 if (Model.IsPartialView)
12 else if (Model.IsLayoutPageSelected)
15 @:ViewData["Title"] = "@Model.ViewName";
16 if (!string.IsNullOrEmpty(Model.LayoutPageFile))
18 @:Layout = "@Model.LayoutPageFile";
22 @:<h2>@Model.ViewName</h2>
35 @:<meta name="viewport" content="width=device-width" />
36 @:<title>@Model.ViewName</title>
42 @:<h4>@Model.ViewDataTypeShortName</h4>
45 @:<div class="col-md-4">
46 @:<form method="post">
47 @:<div asp-validation-summary="ModelOnly" class="text-danger"></div>
48 foreach (var property in Model.ModelMetadata.Properties)
50 if (property.Scaffold && !property.IsAutoGenerated && !property.IsReadOnly)
52 if (property.IsForeignKey)
54 @:<div class="form-group">
55 @:<label asp-for="@(Model.ModelTypeName).@property.PropertyName" class="control-label"></label>
56 @:<select asp-for="@(Model.ModelTypeName).@property.PropertyName" class ="form-control" asp-items="ViewBag.@property.PropertyName"></select>
61 bool isCheckbox = property.TypeName.Equals("System.Boolean");
64 @:<div class="form-group">
65 @:<div class="checkbox">
67 @:<input asp-for="@(Model.ModelTypeName).@property.PropertyName" /> @@Html.DisplayNameFor(model => model.@GetValueExpression(property)))
72 else if (property.IsEnum && !property.IsEnumFlags)
74 @:<div class="form-group">
75 @:<label asp-for="@(Model.ModelTypeName).@property.PropertyName" class="control-label"></label>
76 @:<select asp-for="@(Model.ModelTypeName).@property.PropertyName" class="form-control"></select>
77 @:<span asp-validation-for="@(Model.ModelTypeName).@property.PropertyName" class="text-danger"></span>
82 @:<div class="form-group">
83 @:<label asp-for="@(Model.ModelTypeName).@property.PropertyName" class="control-label"></label>
84 @:<input asp-for="@(Model.ModelTypeName).@property.PropertyName" class="form-control" />
85 @:<span asp-validation-for="@(Model.ModelTypeName).@property.PropertyName" class="text-danger"></span>
91 <div class="form-group">
92 <input type="submit" value="Create" class="btn btn-default" />
99 <a asp-page="Index">Back to List</a>
103 if (Model.ReferenceScriptLibraries)
105 @:@@section Scripts {
106 @:@@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
109 // The following code closes the tag used in the case of a view using a layout page and the body and html tags in the case of a regular view page
110 if (!Model.IsPartialView && !Model.IsLayoutPageSelected)
118 // Do we need to use this in conjunction with the PrimaryKey check?
119 bool IsPropertyGuid(IPropertyMetadata property)
121 return string.Equals("System.Guid", property.TypeName, StringComparison.OrdinalIgnoreCase);
124 string GetValueExpression(IPropertyMetadata property)
126 return property.PropertyName;