using HackerNet.Application; using HackerNet.Domain; namespace HackerNet.Infrastructure.Repositories.Memory; public class MemoryLinkRepository : ILinkRepository, IReadStore { private List _links; public MemoryLinkRepository(params Link[] links) { _links = links.ToList(); } public void Add(Link link) { _links.Add(link); } public LinkHomePage[] GetPublishedLinks() { // return (from l in _links // orderby l.CreatedAt descending // select new LinkHomePage // { // Id = l.Id, // Url = l.Url, // Description = l.Description, // CommentsCount = 0, // }).ToArray(); return _links .OrderByDescending(l => l.CreatedAt) .Select(l => new LinkHomePage { Id = l.Id, Url = l.Url, Description = l.Description, CommentsCount = 0, }).ToArray(); } }