This repository has been archived by the owner on May 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Lesson 12 (Model Validation and Enums)
Sally Steuterman edited this page Jul 28, 2020
·
1 revision
- What ViewModels are and why we should use them.
- How and why to validate model data in ASP.NET.
- How to use C# validation attributes.
- How to employ good error handling when bad data is entered.
- What
enum
data types are and how to write them in C#.
- Check with your course manager for any important announcements.
- Students should have assignment 3 completed by today's class.
-
You may want to introduce the topic of model validation with a more widely-scoped discussion of data handling:
a. Why is good data important?
b. How can bad data be dangerous?
c. Why would using a ViewModel be beneficial in model validation?
-
Be sure that the students can differentiate between client and server side validation tools.
-
Discuss some commonly-used attributes from the C#.
-
Walk the students through the validation flow mentioned in the text, perhaps with a new sample property on
AddEventViewModel
fromCodingEvents
. -
Compare strong error message and handling techniques to weaker examples.
-
Address
enum
data types:a. How to create an
enum
.b. How to add an
enum
type property onto a class.c. What kind of data is handled well with
enums
.
- Today's studio asks students to add validation for the
User
model in their spa day application. If they were not able to complete the user signup studio work from the previous class, they will still be able to work on this studio. - Starter code is provided for the students in the
LaunchCodeEducation/SpaDay
repository. If they have not already added this as anupstream
remote repository in addition to their own forked version, they may need to in order to fetch the appropriate starter branch for the studio. - Students are mostly on their own to decide what their form validation should look like, although most of the work resembles the tasks we
demonstrate in the in-book
CodingEvents
examples. - For those students who try the Bonus Mission, try talking with them about the relative merits of each password checking method.