示例#1
0
        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
            });
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }