public IEnumerable <NewsItemDto> GetAllNews() { var news = _newsItemRepository.GetAllNews().ToList(); news.ForEach(n => { n.Links.AddReference("self", $"api/{n.Id}"); n.Links.AddReference("edit", $"api/{n.Id}"); n.Links.AddReference("delete", $"api/{n.Id}"); n.Links.AddListReference("authors", _authorRepository.GetAuthorsByNewsItemId(n.Id).Select(a => new { href = $"/api/authors/{a.Id}" })); n.Links.AddListReference("categories", _categoryRepository.GetCategoriesByNewsItemId(n.Id).Select(c => new { href = $"/api/categories/{c.Id}" })); }); return(news); }