1 @inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
2 @using Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore
3 @using System.Collections.Generic
5 @@model @Model.ViewDataTypeName
8 if (Model.IsPartialView)
11 else if (Model.IsLayoutPageSelected)
14 @:ViewData["Title"] = "@Model.ViewName";
15 if (!string.IsNullOrEmpty(Model.LayoutPageFile))
17 @:Layout = "@Model.LayoutPageFile";
21 @:<h2>@Model.ViewName</h2>
34 @:<meta name="viewport" content="width=device-width" />
35 @:<title>@Model.ViewName</title>
41 @:<h4>@Model.ViewDataTypeShortName</h4>
44 @:<div class="col-md-4">
45 @:<form asp-action="@Model.ViewName">
46 @:<div asp-validation-summary="ModelOnly" class="text-danger"></div>
47 foreach (var property in Model.ModelMetadata.Properties)
49 if (property.Scaffold && !property.IsAutoGenerated && !property.IsReadOnly)
51 if (property.IsForeignKey)
53 @:<div class="form-group">
54 @:<label asp-for="@property.PropertyName" class="control-label"></label>
55 @:<select asp-for="@property.PropertyName" class ="form-control" asp-items="ViewBag.@property.PropertyName"></select>
60 bool isCheckbox = property.TypeName.Equals("System.Boolean");
63 @:<div class="form-group">
64 @:<div class="checkbox">
66 @:<input asp-for="@property.PropertyName" /> @@Html.DisplayNameFor(model => model.@GetValueExpression(property))
71 else if (property.IsEnum && !property.IsEnumFlags)
73 @:<div class="form-group">
74 @:<label asp-for="@property.PropertyName" class="control-label"></label>
75 @:<select asp-for="@property.PropertyName" class="form-control"></select>
76 @:<span asp-validation-for="@property.PropertyName" class="text-danger"></span>
81 @:<div class="form-group">
82 @:<label asp-for="@property.PropertyName" class="control-label"></label>
83 @:<input asp-for="@property.PropertyName" class="form-control" />
84 @:<span asp-validation-for="@property.PropertyName" class="text-danger"></span>
90 <div class="form-group">
91 <input type="submit" value="Create" class="btn btn-default" />
98 <a asp-action="Index">Back to List</a>
102 if (Model.ReferenceScriptLibraries)
104 @:@@section Scripts {
105 @:@@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
108 // 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
109 if (!Model.IsPartialView && !Model.IsLayoutPageSelected)
117 // Do we need to use this in conjunction with the PrimaryKey check?
118 bool IsPropertyGuid(IPropertyMetadata property)
120 return string.Equals("System.Guid", property.TypeName, StringComparison.OrdinalIgnoreCase);
123 string GetValueExpression(IPropertyMetadata property)
125 return property.PropertyName;