@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade;
@using System.Linq;
@{
// Tell the page that we need the 2sxc Js APIs
Kit.Page.Activate("2sxc.JsCore");
}
<!-- unimportant stuff, hidden -->
Use the sxc data API to create metadata... <!-- unimportant stuff, hidden -->
<table id="example-content" class="table">
<thead>
<tr>
<th>Name</th>
<th>Memberships</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach(var poet in AsList(App.Data["Poets"])) {
var membershipMd = AsList(poet.Metadata.OfType("DeadPoetSocietyMembership") as object);
<tr>
<td>@poet.Name</td>
<td>
@if(membershipMd.Any()) {
foreach (var membership in membershipMd) {
<span>
@membership.MembershipNumber
<a href="#" onclick="window.sxcDataTutorial240.del(@membership.EntityId)">delete</a>
</span>
}
} else {
<button type="button" class="btn btn-primary" onclick='window.sxcDataTutorial240.add("@poet.EntityGuid")'>
add membership (metadata)
</button>
}
</td>
</tr>
}
</tbody>
</table>
@* This tutorial uses turnOn, see https://app-dev.2sxc.org/tutorial-razor/en-bs4/Home/turn-on/home *@
@{ Kit.Page.Activate("turnOn"); }
<turnOn turn-on='{ "run": "window.sxcDataTutorial240.init()", "data": { "moduleId": "@CmsContext.Module.Id" } }'></turnOn>
<script src="@App.Path/js/_310-create metadata.js"></script>
<!-- unimportant stuff, hidden -->