public UsersCollection(NancyContext context, IEnumerable <Domain.User> users) : base(context.Request.Url.ToString(), new[] { "users", "collection" })
        {
            int pageNumber   = context.Request.Query.PageNumber;
            int pageSize     = context.Request.Query.PageSize;
            int totalEntries = users.Count();

            var usersPage = users.Skip(pageNumber * pageSize).Take(pageSize);

            Properties = new Dictionary <string, object> {
                { "Page Details", PagedProperties.GetPageDetails(pageNumber, pageSize, totalEntries) }
            };
            Entities = new List <Entity>(usersPage.Select(x => new UsersCollectionItem(context, x)));
            Links    = new LinksFactory(context).WithPage <GetUsers>(pageNumber, pageSize, totalEntries).Build();
        }
Exemple #2
0
        public InventoryCollection(NancyContext context, ICollection <InventoryListItemDto> items)
            : base(context.Request.Url.ToString(), new[] { "inventory", "collection" })
        {
            int pageNumber   = context.Request.Query.PageNumber;
            int pageSize     = context.Request.Query.PageSize;
            int totalEntries = items.Count;

            var booksPage = items.Skip(pageNumber * pageSize).Take(pageSize);

            Properties = new Dictionary <string, object> {
                { "Page Details", PagedProperties.GetPageDetails(pageNumber, pageSize, totalEntries) }
            };
            Entities = new List <Entity>(booksPage.Select(x => new InventoryCollectionItem(context, x)));
            Links    = new LinksFactory(context).WithPage <GetInventoryLink>(pageNumber, pageSize, totalEntries).Build();
            Actions  = new ActionsFactory(context).With(new AddInventoryItemAction()).Build();
        }