public ReservationsController(IReservationService reservationService, IUserService userService, IBookService bookService, ILoanService loanService) { this.reservationService = reservationService; this.userService = userService; this.bookService = bookService; this.loanService = loanService; this.serviceDataLookUp = new DefaultServiceDataLookUp(loanService, reservationService); }
public BooksController(IBookFacade bookFacade, IAuthorService authorService, IPublisherService publisherService, IReservationService reservationService, ILoanService loanService) { this.bookFacade = bookFacade; this.authorService = authorService; this.publisherService = publisherService; this.reservationService = reservationService; this.loanService = loanService; this.serviceDataLookUp = new DefaultServiceDataLookUp(loanService, reservationService); }
public async static Task <BookDTO> ToBookViewItem(this Book book, IServiceDataLookUp serviceDataLookUp) { var bookDTO = new BookDTO() { Id = book.Id, Authors = book.Authors.Select(a => a.Author.ToAuthorViewItem()).ToArray(), Isbn = book.Isbn.Value, Publisher = book.Publisher.ToPublisherViewItem(), PublicationYear = book.PublicationYear, Title = book.Title, Synopsis = book.Synopsis, NumberOfCopies = book.NumberOfCopies, CoverImageKey = book.CoverImageKey, }; var reservations = await serviceDataLookUp.LookUp(book); bookDTO.Reservations = await reservations.ToReservationViewItems(serviceDataLookUp); return(bookDTO); }
public async static Task <IEnumerable <ReservationResultDTO> > ToReservationViewItems(this IEnumerable <Reservation> reservations, IServiceDataLookUp serviceDataLookUp) { return(await Task.WhenAll(reservations.Select(r => r.ToReservationViewItem(serviceDataLookUp)))); }
public async static Task <ReservationResultDTO> ToReservationViewItem(this Reservation reservation, IServiceDataLookUp serviceDataLookUp) { var reservationDTO = new ReservationResultDTO() { Id = reservation.Id, BookId = reservation.BookId, UserId = reservation.User.Id, Description = reservation.Reason.Description, StatusId = (long)reservation.Reason.Status, StartDate = reservation.StartDate }; var loan = await serviceDataLookUp.LookUp(reservation); if (loan != null) { reservationDTO.Loan = loan.ToLoanViewItem(); } return(reservationDTO); }
public async static Task <IEnumerable <BookDTO> > ToBookViewItems(this IEnumerable <Book> books, IServiceDataLookUp serviceDataLookUp) { return(await Task.WhenAll(books.Select(b => b.ToBookViewItem(serviceDataLookUp)))); }