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
|
@inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
@using System.Collections.Generic
@using System.Linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
@{
var entitySetName = Model.ModelMetadata.EntitySetName;
var entitySetVar = Model.EntitySetVariable ??
(String.IsNullOrEmpty(entitySetName)
? entitySetName
: (entitySetName.Substring(0, length: 1).ToLowerInvariant() + entitySetName.Substring(1)));
var relatedProperties = new Dictionary<string, dynamic>();
foreach (var nav in Model.ModelMetadata.Navigations)
{
relatedProperties.Add(nav.AssociationPropertyName, nav);
}
foreach (var namespaceName in Model.RequiredNamespaces)
{
@:using @namespaceName;
}
}
namespace @Model.NamespaceName
{
public class @Model.PageModelClassName : PageModel
{
private readonly @Model.ContextTypeName _context;
public @(Model.PageModelClassName)(@Model.ContextTypeName context)
{
_context = context;
}
public IActionResult OnGet()
{
@{
foreach (var property in relatedProperties.Values)
{
@:ViewData["@(property.ForeignKeyPropertyNames[0])"] = new SelectList(_context.@property.EntitySetName, "@property.PrimaryKeyNames[0]", "@property.DisplayPropertyName");
}
}
return Page();
}
[BindProperty]
public @Model.ViewDataTypeShortName @Model.ViewDataTypeShortName { get; set; }
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.@(entitySetName).Add(@Model.ViewDataTypeShortName);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
}
}
|
Revision |
Author |
Commited |
Message |
1
|
BBDSCHRIS
|
Wed 22 Aug, 2018 20:08:03 +0000 |
|