Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
ASP.NET Core 2 and Angular 5

You're reading from   ASP.NET Core 2 and Angular 5 Full-stack web development with .NET Core and Angular

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788293600
Length 550 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Valerio De Sanctis Valerio De Sanctis
Author Profile Icon Valerio De Sanctis
Valerio De Sanctis
Jürgen Gutsch Jürgen Gutsch
Author Profile Icon Jürgen Gutsch
Jürgen Gutsch
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
1. Getting Ready 2. Backend with .NET Core FREE CHAPTER 3. Frontend with Angular 4. Data Model with Entity Framework Core 5. Client-Server Interactions 6. Style Sheets and UI Layout 7. Forms and Data Validation 8. Authentication and Authorization 9. Advanced Topics 10. Finalization and Deployment

Updating the QuizController


Last but not least, we need to make some changes to the QuizController to make it use the ApplicationDbContext to retrieve data instead of those Dummy Data Provider strategies we implemented back in Chapter 2, Backend with .NET Core.

In order to do that, the first thing we need to do is to find an efficient way to map each Quiz entity to a corresponding QuizViewModel object, as our new Data Provider won’t generate them anymore. We can achieve such a result in a number of ways, including the following:

  • Adding a Helper Method, such as GetQuizViewModel(Quiz quiz), thus handling the mapping manually with a few lines of code
  • Adding a Constructor Method to the QuizViewModel itself, such as QuizViewModel(Quiz quiz), doing pretty much the same thing as the aforementioned helper method
  • Adding one of the many Object-to-Object Auto-Mapping Tools freely available via NuGet and configuring it to handle the mapping automatically whenever we need it

We’ll definitely go for the latter...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images