protected IEnumerable <LinkDto> CreateLinksForCollection <T> (PagedList <T> resources, IResourceParameters parameters) where T : AuditableEntity { var links = new List <LinkDto>(); var resourceUriHelper = new ResourceUriHelper(Url); var resourceUri = pagination.CreateResourceUri (parameters, resourceUriHelper, ResourceUriType.Current); links.Add(new LinkDto(resourceUri, "self", "GET")); var pagesLinks = pagination.CreatePagesLinks(resources, parameters, resourceUriHelper); if (pagesLinks.HasPrevious) { links.Add(new LinkDto(pagesLinks.Previous, "previousPage", "GET")); } if (pagesLinks.HasNext) { links.Add(new LinkDto(pagesLinks.Next, "nextPage", "GET")); } return(links); }
public PagedList <Comment> GetAllComentsForPost (Guid postId, IResourceParameters parameters) { var comments = context.Comments .Where(comment => postId == comment.PostId).AsNoTracking(); if (!string.IsNullOrWhiteSpace(parameters.OrderBy)) { comments = SortComments(comments, parameters.OrderBy); } return(PagedList <Comment> .Create (comments, parameters.PageNumber, parameters.PageSize)); }
public PagedList <Author> GetAllAuthors(IResourceParameters parameters) { var authors = context.Authors.AsNoTracking(); return(PagedList <Author> .Create(authors, parameters.PageNumber, parameters.PageSize)); }
protected dynamic GetCollectionWithLinks <T>(PagedList <T> resources, IEnumerable <ExpandoObject> shapedResources, IResourceParameters parameters) where T : AuditableEntity { var ids = GetIds(resources).ToList(); return(new { value = GetLinkedResources(shapedResources, ids, parameters.Fields), links = CreateLinksForCollection(resources, parameters) }); }
private bool CantValidate(IResourceParameters parameters, bool fullMedia) { return(validator.DontMatchRules(parameters, ModelState) || OrderIsInvalid(parameters.OrderBy, fullMedia) || FieldsAreInvalid(parameters.Fields, fullMedia)); }