public Publisher FindById(Guid key) { var epublisher = _publisherContext.GetItemById(Convert.ToString(key)); var publisher = PublisherMapping.MapToPublisher(epublisher); epublisher.BookIds.ToList().ForEach((bkId) => { var bk = _bookContext.GetItemById(bkId); publisher.Books.Add(new Book() { BookId = Guid.Parse(bk.Id), title = bk.Title }); }); return(publisher); }
public IList <Publisher> FindAll() { var _publishers = _publisherContext.GetItems(); var publishers = new List <Publisher>(); var books = _bookContext.GetItems(); _publishers.ForEach((currentPublisher) => { var pub = PublisherMapping.MapToPublisher(currentPublisher); var ebooks = books.FindAll(bk => Guid.Parse(bk.PublisherId) == pub.EntityIdentityKey); if (ebooks != null && ebooks.Count() > 0) { ebooks.ForEach((bk) => { pub.Books.Add(new Book() { BookId = Guid.Parse(bk.Id), title = bk.Title }); }); } publishers.Add(pub); }); return(publishers.ToList()); }