#include "AddressBook.h" void Persons(Http& http) { ValueArray person; SqlBool where; String s = http["search"]; if(!IsNull(s)) { s << '%'; where = Like(FIRSTNAME, s) || Like(LASTNAME, s) || Like(EMAIL, s); } ValueMap vm; Sql sql; sql * Select(ID, FIRSTNAME, LASTNAME, EMAIL) .From(PERSON) .Where(where) .OrderBy(LASTNAME, FIRSTNAME); while(sql.Fetch(vm)) person.Add(vm); http("PERSON", person); }; SKYLARK(HomePage, "") { Persons(http); http.RenderResult("AddressBookWeb/Index"); } SKYLARK(CatchAll, "**") { http.Redirect(HomePage); } SKYLARK(SubmitNew, "submit/create:POST") { SQL * http.Insert(PERSON); http.Redirect(HomePage); } SKYLARK(New, "person/create") { http("ACTION", SubmitNew).RenderResult("AddressBookWeb/Dialog"); } SKYLARK(SubmitEdit, "submit/edit/*:POST") { SQL * http.Update(PERSON).Where(ID == http.Int(0)); http.Redirect(HomePage); } SKYLARK(Edit, "person/*/edit") { int id = http.Int(0); Sql sql; sql * Select(FIRSTNAME, LASTNAME, EMAIL) .From(PERSON) .Where(ID == id); if(!sql.Fetch()) { http.Redirect(HomePage); return; } http (sql) ("ID", id) ("ACTION", SubmitEdit, id) .RenderResult("AddressBookWeb/Dialog"); } SKYLARK(Delete, "person/*/delete") { SQL * Delete(PERSON).Where(ID == atoi(http[0])); DeleteFile(ConfigFile(atoi(http[0]) + ".data")); http.Redirect(HomePage); }