private dynamic GetProfiles() { var index = (int?)Request.Query["index"] ?? 0; var count = 10; var profiles = db.ListProfiles().Skip(index).Take(count); var total = db.CountProfiles(); var links = Hal.Paginate("/profiles", index, count, total); return(new { _links = links, items = profiles }); }
public object Get(int index = 0) { var RESULTS_PER_PAGE = 10; var profiles = db.ListProfiles() .Skip(index) .Take(RESULTS_PER_PAGE); var total = db.CountProfiles(); var result = new { _links = Hal.Paginate("/profiles", index, RESULTS_PER_PAGE, total), items = profiles }; return(result); }
public object GetProfiles(int index = 0, int count = 10) { var _links = Hal.Paginate(Request.RequestUri.AbsolutePath, index, count, db.CountProfiles()); var items = db.ListProfiles().Skip(index).Take(count).Select(profile => profile.ToResource()); var _actions = new { create = new { name = "Create a new profile", href = Request.RequestUri.AbsolutePath, method = "POST", type = "application/json", schema = new { href = "/schemas/profile.json" } } }; var result = new { _links, _actions, items }; return(result); }