示例#1
0
        public LocationInLibraryBooksViewModel GetLocationInLibraryBooks(Guid locationInLibraryID)
        {
            LocationInLibraryBooksViewModel locationInLibraryBooksViewModel = new LocationInLibraryBooksViewModel();
            LocationInLibrary locationInLibrary = booksLibraryDataContext.LocationInLibraries.FirstOrDefault(x => x.IDLocationInLibrary == locationInLibraryID);

            if (locationInLibrary != null)
            {
                locationInLibraryBooksViewModel.Name   = locationInLibrary.Name;
                locationInLibraryBooksViewModel.Floor  = locationInLibrary.Floor;
                locationInLibraryBooksViewModel.Sector = locationInLibrary.Sector;
                locationInLibraryBooksViewModel.Shelf  = locationInLibrary.Shelf;

                IQueryable <Book> locationInLibraryBooks = booksLibraryDataContext.Books.Where(x => x.IDLocationInLibrary == locationInLibraryID);
                foreach (Book dbBook in locationInLibraryBooks)
                {
                    Models.BookModel bookModel = new Models.BookModel();
                    bookModel.Name           = dbBook.Name;
                    bookModel.Author         = dbBook.Author;
                    bookModel.Publisher      = dbBook.Publisher;
                    bookModel.NumberOfCopies = dbBook.NumberOfCopies;


                    locationInLibraryBooksViewModel.Books.Add(bookModel);
                }
            }
            return(locationInLibraryBooksViewModel);
        }
示例#2
0
        // GET: LocationInLibrary/Details/5
        public ActionResult Details(Guid id)
        {
            LocationInLibraryBooksViewModel viewModel = locationInLibraryRepository.GetLocationInLibraryBooks(id);

            return(View(viewModel));
        }