Subversion Repository Public Repository

ChrisCompleteCodeTrunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
@inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
@using Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore
@using System.Collections.Generic
@using System.Linq
@@page
@@model @Model.NamespaceName.@Model.PageModelClassName

@{
    if (Model.IsPartialView)
    {
    }
    else if (Model.IsLayoutPageSelected)
    {
@:@@{
    @:ViewData["Title"] = "@Model.RazorPageName";
        if (!string.IsNullOrEmpty(Model.LayoutPageFile))
        {
    @:Layout = "@Model.LayoutPageFile";
        }
@:}
@:
@:<h2>@Model.RazorPageName</h2>
@:
    }
    else
    {
@:@@{
    @:Layout = null;
@:}
@:
@:<!DOCTYPE html>
@:
@:<html>
@:<head>
    @:<meta name="viewport" content="width=device-width" />
    @:<title>@Model.RazorPageName</title>
@:</head>
@:<body>
@:
        //    PushIndent("    ");
    }
@:<h4>@Model.ViewDataTypeShortName</h4>
@:<hr />
@:<div class="row">
    @:<div class="col-md-4">
        @:<form method="post">
            @:<div asp-validation-summary="ModelOnly" class="text-danger"></div>
        foreach (PropertyMetadata property in Model.ModelMetadata.Properties)
        {
            if (property.IsPrimaryKey)
            {
            @:<input type="hidden" asp-for="@(Model.ModelTypeName).@property.PropertyName" />
                continue;
            }

            if (property.Scaffold)
            {
                if (property.IsReadOnly)
                {
                    continue;
                }

                if (property.IsForeignKey)
                {
            @:<div class="form-group">
                @:<label asp-for="@(Model.ModelTypeName).@property.PropertyName" class="control-label"></label>
                @:<select asp-for="@(Model.ModelTypeName).@property.PropertyName" class="form-control" asp-items="ViewBag.@property.PropertyName"></select>
                @:<span asp-validation-for="@(Model.ModelTypeName).@property.PropertyName" class="text-danger"></span>
            @:</div>
                    continue;
                }

                bool isCheckbox = property.TypeName.Equals("System.Boolean");
                if (isCheckbox)
                {
            @:<div class="form-group">
                @:<div class="checkbox">
                    @:<label>
                        @:<input asp-for="@(Model.ModelTypeName).@property.PropertyName" /> @@Html.DisplayNameFor(model => model.@GetValueExpression(property))
                    @:</label>
                @:</div>
            @:</div>
                }
                else if (property.IsEnum && !property.IsEnumFlags)
                {
            @:<div class="form-group">
                @:<label asp-for="@(Model.ModelTypeName).@property.PropertyName" class="control-label"></label>
                @:<select asp-for="@(Model.ModelTypeName).@property.PropertyName" class="form-control"></select>
                @:<span asp-validation-for="@(Model.ModelTypeName).@property.PropertyName" class="text-danger"></span>
            @:</div>
                }
                else if (property.IsMultilineText)
                {
            @:<div class="form-group">
                @:<label asp-for="@(Model.ModelTypeName).@property.PropertyName" class="control-label"></label>
                @:<textarea asp-for="@(Model.ModelTypeName).@property.PropertyName" class="form-control"></textarea>
                @:<span asp-validation-for="@(Model.ModelTypeName).@property.PropertyName" class="text-danger"></span>
            @:</div>
                }
                else
                {
            @:<div class="form-group">
                @:<label asp-for="@(Model.ModelTypeName).@property.PropertyName" class="control-label"></label>
                @:<input asp-for="@(Model.ModelTypeName).@property.PropertyName" class="form-control" />
                @:<span asp-validation-for="@(Model.ModelTypeName).@property.PropertyName" class="text-danger"></span>
            @:</div>
                }
            }
            // Ideally we shouldn't be here  but if the user marks the foreign key as [ScaffoldColumn(false)], we want to atleast try to make it work.
            else if (property.IsForeignKey)
            {
        @:<input type="hidden" asp-for="@(Model.ModelTypeName).@property.PropertyName" />
                continue;
            }
        }
    }
            <div class="form-group">
                <input type="submit" value="Save" class="btn btn-default" />
            </div>
        </form>
    </div>
</div>

<div>
    <a asp-page="./Index">Back to List</a>
</div>

@{
    if (Model.ReferenceScriptLibraries)
    {
@:@@section Scripts {
    @:@@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
@:}
    }
    // 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
    if (!Model.IsPartialView && !Model.IsLayoutPageSelected)
    {
@:</body>
@:</html>
    }
}
@functions
{
    string GetAssociationName(IPropertyMetadata property)
    {
        //Todo: Implement properly.
        return property.PropertyName;
    }

    string GetValueExpression(IPropertyMetadata property)
    {
        return property.PropertyName;
    }
}

Commits for ChrisCompleteCodeTrunk/ActionTireCo/packages/Microsoft.VisualStudio.Web.CodeGenerators.Mvc.2.1.0/Templates/RazorPageGenerator/Edit.cshtml

Diff revisions: vs.
Revision Author Commited Message
1 BBDSCHRIS picture BBDSCHRIS Wed 22 Aug, 2018 20:08:03 +0000