File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
LibraryManagement.Api/Services/Foundations/ReaderBooks Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ //-----------------------------------------------------------
2+ // Copyright (c) Coalition of Good-Hearted Engineers
3+ // Free To Use To Build Reliable Library Management Solutions
4+ //-----------------------------------------------------------
5+
6+ using LibraryManagement . Api . Models . Foundations . ReaderBooks ;
7+
8+ namespace LibraryManagement . Api . Services . Foundations . ReaderBooks
9+ {
10+ public interface IReaderBookService
11+ {
12+ ValueTask < ReaderBook > RetrieveReaderBookByIdAsync ( Guid readerId ) ;
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ //-----------------------------------------------------------
2+ // Copyright (c) Coalition of Good-Hearted Engineers
3+ // Free To Use To Build Reliable Library Management Solutions
4+ //-----------------------------------------------------------
5+
6+ using LibraryManagement . Api . Models . Foundations . Books ;
7+ using LibraryManagement . Api . Models . Foundations . ReaderBooks ;
8+ using LibraryManagement . Api . Models . Foundations . Readers ;
9+ using LibraryManagement . Api . Services . Foundations . Books ;
10+ using LibraryManagement . Api . Services . Foundations . Readers ;
11+
12+ namespace LibraryManagement . Api . Services . Foundations . ReaderBooks
13+ {
14+ public class ReaderBookService : IReaderBookService
15+ {
16+ private readonly IReaderService readerService ;
17+ private readonly IBookService bookService ;
18+
19+ public ReaderBookService (
20+ IReaderService readerService ,
21+ IBookService bookService )
22+ {
23+ this . readerService = readerService ;
24+ this . bookService = bookService ;
25+ }
26+
27+ public async ValueTask < ReaderBook > RetrieveReaderBookByIdAsync ( Guid readerId )
28+ {
29+ Reader reader =
30+ await this . readerService . RetrieveReaderByIdAsync ( readerId ) ;
31+
32+ IQueryable < Book > allBooks =
33+ this . bookService . RetrieveAllBooks ( ) ;
34+
35+ List < Book > booksForReader = allBooks
36+ . Where ( book => book . ReaderId == readerId )
37+ . ToList ( ) ;
38+
39+ return new ReaderBook
40+ {
41+ Reader = reader ,
42+ Books = booksForReader
43+ } ;
44+ }
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments