public IEnumerable <NewsItemDto> GetAllNewsItemsByAuthorId(int authorId) { var entity = _newsItemRepository.GetAllNewsItemsByAuthorId(authorId).ToList(); entity.ForEach(r => { var authorIds = _newsItemRepository.GetAllAuthorIdByNewsItemId(r.Id).ToList(); var categoryIds = _categoryRepository.GetAllCategoriesIdByNewsItemId(r.Id).ToList(); r.Links.AddReference("self", new { href = $"api/{r.Id}" }); r.Links.AddReference("edit", new { href = $"api/{r.Id}" }); r.Links.AddReference("delete", new { href = $"api/{r.Id}" }); authorIds.ForEach(s => { r.Links.AddReference("authors", new { href = $"api/authors/{s}" }); }); categoryIds.ForEach(s => { r.Links.AddReference("categories", new { href = $"api/authors/{s}" }); }); }); return(entity); }