Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
64 lines (55 sloc)
1.82 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using EmailContacts.ServiceInterface | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>Email Contacts</title> | |
<script type="text/javascript" src="Scripts/jquery-2.1.3.js"></script> | |
<script type="text/javascript" src="Scripts/bootstrap.js"></script> | |
<link href="Content/bootstrap.css" rel="stylesheet" /> | |
<link href="Content/bootstrap-theme.css" rel="stylesheet" /> | |
<style type="text/css"> | |
body { | |
margin: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<h3>Db.Select</h3> | |
<ul> | |
@foreach (var contact in Db.Select<Contact>()) | |
{ | |
<li>@contact.Name @contact.Email (@contact.Age)</li> | |
} | |
</ul> | |
<h3>ResolveService / Get</h3> | |
<ul> | |
@using (var service = Get<ContactsServices>()) | |
{ | |
var contacts = service.Any(new FindContacts()); | |
foreach (var contact in contacts) | |
{ | |
<li>@contact.Name @contact.Email (@contact.Age)</li> | |
} | |
} | |
</ul> | |
<h3>Embedded JSON</h3> | |
<ul id="embedded-json"></ul> | |
<h3>$.getJSON</h3> | |
<ul id="ajax"></ul> | |
<script> | |
//Embed JSON | |
$("#embedded-json").append( | |
contactsHtml(@(Db.Select<Contact>().AsRawJson()))); | |
//Ajax | |
$.getJSON("/contacts", addContacts); | |
function addContacts(contacts) { | |
$("#ajax").append(contactsHtml(contacts)); | |
} | |
function contactsHtml(contacts) { | |
return contacts.map(function (c) { | |
return "<li>" + c.Name + " " + " (" + c.Age + ")" + "</li>"; | |
}).join(''); | |
} | |
</script> | |
</body> | |
</html> |