Download presentation
Presentation is loading. Please wait.
1
MIS 324 -- Professor Sandvig MIS 324 Professor Sandvig
12/4/2018 MVC Models MIS 324 Professor Sandvig
2
Recap Photos exercise Controller: Handles http requests
Request includes: controller name action method name Example: ~/photos/dahlia Action method name optional Defaults to “index”
3
Recap Controller Optional parameters ViewBag Give each object a name
Example: photos/photoView?id=dahlia Photos/photoView/dahlia ViewBag Passes values from controller to view Give each object a name Eg: ViewBag.photo = “dahlia”;
4
Today Will add simple model What is model How to define model
Benefits How to define model Accessing from controller Passing to view
5
What is Model Model describes data Typically a real-world entity
Customer Product Order Transaction Etc.
6
Benefits of Models Pass all properties in a single object Validation
Pass one object Rather than each property Validation Specify data type in model required, length, format, , etc. Easy!
7
Benefits of Models Visual Studio wizards Uses model to create forms
Includes Validation
8
How to Define Model Add new class to model folder Syntax:
9
Accessing Model from Controller
Need to add using statement Points to “Models” namespace
10
Passing Model to from Controller
11
MIS 324 -- Professor Sandvig
12/4/2018 Summary MVC Models Define business entities Employees Customers Products All properties in single object Pass as single object Validation in definition Visual Studio wizards
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.