[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 / RazorPageGenerator / 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 @@page
6 @@model @Model.NamespaceName.@Model.PageModelClassName
7
8 @{
9     if (Model.IsPartialView)
10     {
11     }
12     else if (Model.IsLayoutPageSelected)
13     {
14 @:@@{
15     @:ViewData["Title"] = "@Model.ViewName";
16         if (!string.IsNullOrEmpty(Model.LayoutPageFile))
17         {
18     @:Layout = "@Model.LayoutPageFile";
19         }
20 @:}
21 @:
22 @:<h2>@Model.ViewName</h2>
23 @:
24     }
25     else
26     {
27 @:@@{
28     @:Layout = null;
29 @:}
30 @:
31 @:<!DOCTYPE html>
32 @:
33 @:<html>
34 @:<head>
35     @:<meta name="viewport" content="width=device-width" />
36     @:<title>@Model.ViewName</title>
37 @:</head>
38 @:<body>
39 @:
40         //    PushIndent("    ");
41     }
42 @:<h4>@Model.ViewDataTypeShortName</h4>
43 @:<hr />
44 @:<div class="row">
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)
49         {
50             if (property.Scaffold && !property.IsAutoGenerated && !property.IsReadOnly)
51             {
52                 if (property.IsForeignKey)
53                 {
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>
57             @:</div>
58                     continue;
59                 }
60
61                 bool isCheckbox = property.TypeName.Equals("System.Boolean");
62                 if (isCheckbox)
63                 {
64             @:<div class="form-group">
65                 @:<div class="checkbox">
66                     @:<label>
67                         @:<input asp-for="@(Model.ModelTypeName).@property.PropertyName" /> @@Html.DisplayNameFor(model => model.@GetValueExpression(property)))
68                     @:</label>
69                 @:</div>
70             @:</div>
71                 }
72                 else if (property.IsEnum && !property.IsEnumFlags)
73                 {
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>
78             @:</div>
79                 }
80                 else
81                 {
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>
86             @:</div>
87                 }
88             }
89         }
90     }
91             <div class="form-group">
92                 <input type="submit" value="Create" class="btn btn-default" />
93             </div>
94         </form>
95     </div>
96 </div>
97
98 <div>
99     <a asp-page="Index">Back to List</a>
100 </div>
101
102 @{
103     if (Model.ReferenceScriptLibraries)
104     {
105 @:@@section Scripts {
106     @:@@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
107 @:}
108     }
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)
111     {
112 @:</body>
113 @:</html>
114     }
115 }
116 @functions
117 {
118     // Do we need to use this in conjunction with the PrimaryKey check?
119     bool IsPropertyGuid(IPropertyMetadata property)
120     {
121         return string.Equals("System.Guid", property.TypeName, StringComparison.OrdinalIgnoreCase);
122     }
123
124     string GetValueExpression(IPropertyMetadata property)
125     {
126         return property.PropertyName;
127     }
128 }