Esempio n. 1
0
        public IActionResult Add(int id)
        {
            var book   = _bookService.Get(id);
            var author = _authorService.Get(id);
            var model  = new BookListingModel
            {
                Title  = book.Title,
                Author = author.FName,
                Whom   = book.Whom
            };

            Console.WriteLine(book);
            return(View(model));
        }
Esempio n. 2
0
        private IEnumerable <BookListingModel> GetBookListingModels(IEnumerable <BookListing> listings)
        {
            var books = new List <BookListingModel>();

            foreach (var listing in listings.OrderByDescending(l => l.PublishedOn))
            {
                // Create model for page
                var viewModel = BookListingModel.FromListing(listing);

                // Set image URLs
                if (listing.ImageId != null)
                {
                    viewModel.ImageThumbnailUrl = appSettings.Value.ImagesFolder + listing.ImageId + "_thumb.jpg";
                    viewModel.ImageFullUrl      = appSettings.Value.ImagesFolder + listing.ImageId + ".jpg";
                }

                books.Add(viewModel);
            }

            return(books);
        }
        public IEnumerable <BookListingModel> GetBookListingModels()
        {
            var listings  = this.GetBookListings().OrderByDescending(l => l.PublishedOn);
            var books     = new List <BookListingModel>();
            var imagePath = ConfigurationManager.AppSettings["DataFolderRelativePath"] + "images/";

            foreach (var listing in listings)
            {
                // Create model for page
                var viewModel = BookListingModel.FromListing(listing);

                // Set image URLs
                if (listing.ImageId != null)
                {
                    viewModel.ImageThumbnailUrl = imagePath + listing.ImageId + "_thumb.jpg";
                    viewModel.ImageFullUrl      = imagePath + listing.ImageId + ".jpg";
                }

                books.Add(viewModel);
            }

            return(books);
        }
        public IEnumerable <BookListingModel> GetBookListingModels()
        {
            var listings  = this.GetBookListings().OrderByDescending(l => l.PublishedOn);
            var books     = new List <BookListingModel>();
            var imagePath = ConfigurationManager.AppSettings["ImageContainerURL"]; //"http://127.0.0.1:10000/devstoreaccount1/" + "images/";

            foreach (var listing in listings)
            {
                // Create model for page
                var viewModel = BookListingModel.FromListing(listing);

                // Set image URLs
                if (listing.ImageId != null)
                {
                    viewModel.ImageThumbnailUrl = imagePath + "/" + listing.ImageId + "_thumb.jpg";
                    viewModel.ImageFullUrl      = imagePath + "/" + listing.ImageId + ".jpg";
                }

                books.Add(viewModel);
            }

            return(books);
        }