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);
        }
示例#2
0
        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);
        }