[Tizen] Add BuildTools 2.1.0-rc1-02804-05
[platform/upstream/coreclr.git] / Tools / dotnetcli / sdk / NuGetFallbackFolder / microsoft.visualstudio.web.codegenerators.mvc / 2.0.1 / Templates / ViewGenerator / Create.cshtml
1 @inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
2 @using Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore
3 @using System.Collections.Generic
4 @using System.Linq
5 @@model @Model.ViewDataTypeName
6
7 @{
8     if (Model.IsPartialView)
9     {
10     }
11     else if (Model.IsLayoutPageSelected)
12     {
13 @:@@{
14     @:ViewData["Title"] = "@Model.ViewName";
15         if (!string.IsNullOrEmpty(Model.LayoutPageFile))
16         {
17     @:Layout = "@Model.LayoutPageFile";
18         }
19 @:}
20 @:
21 @:<h2>@Model.ViewName</h2>
22 @:
23     }
24     else
25     {
26 @:@@{
27     @:Layout = null;
28 @:}
29 @:
30 @:<!DOCTYPE html>
31 @:
32 @:<html>
33 @:<head>
34     @:<meta name="viewport" content="width=device-width" />
35     @:<title>@Model.ViewName</title>
36 @:</head>
37 @:<body>
38 @:
39         //    PushIndent("    ");
40     }
41 @:<h4>@Model.ViewDataTypeShortName</h4>
42 @:<hr />
43 @:<div class="row">
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)
48         {
49             if (property.Scaffold && !property.IsAutoGenerated && !property.IsReadOnly)
50             {
51                 if (property.IsForeignKey)
52                 {
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>
56             @:</div>
57                     continue;
58                 }
59
60                 bool isCheckbox = property.TypeName.Equals("System.Boolean");
61                 if (isCheckbox)
62                 {
63             @:<div class="form-group">
64                 @:<div class="checkbox">
65                     @:<label>
66                         @:<input asp-for="@property.PropertyName" /> @@Html.DisplayNameFor(model => model.@GetValueExpression(property))
67                     @:</label>
68                 @:</div>
69             @:</div>
70                 }
71                 else if (property.IsEnum && !property.IsEnumFlags)
72                 {
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>
77             @:</div>
78                 }
79                 else
80                 {
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>
85             @:</div>
86                 }
87             }
88         }
89         }
90             <div class="form-group">
91                 <input type="submit" value="Create" class="btn btn-default" />
92             </div>
93         </form>
94     </div>
95 </div>
96
97 <div>
98     <a asp-action="Index">Back to List</a>
99 </div>
100
101 @{
102     if (Model.ReferenceScriptLibraries)
103     {
104 @:@@section Scripts {
105     @:@@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
106 @:}
107     }
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)
110     {
111 @:</body>
112 @:</html>
113     }
114 }
115 @functions
116 {
117     // Do we need to use this in conjunction with the PrimaryKey check?
118     bool IsPropertyGuid(IPropertyMetadata property)
119     {
120         return string.Equals("System.Guid", property.TypeName, StringComparison.OrdinalIgnoreCase);
121     }
122
123     string GetValueExpression(IPropertyMetadata property)
124     {
125         return property.PropertyName;
126     }
127 }