You are developing an ASP.NET MVC application in Visual Studio 2012 that will be used by Olympic marathon runners to log data about training runs.
The application stores date, distance, and duration information about a user's training runs.
The user can view, insert, edit, and delete records.
The application must be optimized for accessibility.
All times must be displayed in the user's local time.
Data Access:
Database access is handled by a public class named RunnerLog.DataAccess.RunnerLogDb.
All data retrieval must be done by HTTP GET and all data updates must be done by HTTP POST.
Layout:
All pages in the application use a master layout file named \Views\Shared\_Layout.cshtml.
Models:
The application uses the \Models\LogModel.cs model.
Views:
All views in the application use the Razor view engine.
Four views located in \Views\RunLog are named:
_CalculatePace.cshtml
EditLog.cshtml
GetLog.cshtml
InsertLog.cshtml
The application also contains a \Views\Home\Index.cshtml view.
Controllers:
The application contains a \Controllers\RunLogController.cs controller.
Images:
A stopwatch.png image is located in the \Images folder.
Videos:
A map of a runner's path is available when a user views a run log. The map is implemented as an Adobe Flash application and video. The browser should display the video natively if possible, using H264, Ogg, or WebM formats, in that order. If the video cannot be displayed, then the Flash application should be used.
Security:
You have the following security requirements:
The application is configured to use forms authentication.
Users must be logged on to insert runner data.
Users must be members of the Admin role to edit or delete runner data.
There are no security requirements for viewing runner data.
You need to protect the application against cross-site request forgery.
Passwords are hashed by using the SHA1 algorithm.
RunnerLog.Providers.RunLogRoleProvider.cs contains a custom role provider.
Relevant portions of the application files follow. (Line numbers are included for reference only.)
Background
You are developing an ASP.NET MVC application in Visual Studio 2012 that will be used by Olympic marathon runners to log data about training runs.
Business Requirements
The application stores date, distance, and duration information about a user's training runs.
The user can view, insert, edit, and delete records.
The application must be optimized for accessibility.
All times must be displayed in the user's local time.
Technical Requirements
Data Access:
Database access is handled by a public class named RunnerLog.DataAccess.RunnerLogDb.
All data retrieval must be done by HTTP GET and all data updates must be done by HTTP POST.
Layout:
All pages in the application use a master layout file named \Views\Shared\_Layout.cshtml.
Models:
The application uses the \Models\LogModel.cs model.
Views:
All views in the application use the Razor view engine.
Four views located in \Views\RunLog are named:
_CalculatePace.cshtml
EditLog.cshtml
GetLog.cshtml
InsertLog.cshtml
The application also contains a \Views\Home\Index.cshtml view.
Controllers:
The application contains a \Controllers\RunLogController.cs controller.
Images:
A stopwatch.png image is located in the \Images folder.
Videos:
A map of a runner's path is available when a user views a run log. The map is implemented as an Adobe Flash application and video. The browser should display the video natively if possible, using H264, Ogg, or WebM formats, in that order. If the video cannot be displayed, then the Flash application should be used.
Security:
You have the following security requirements:
The application is configured to use forms authentication.
Users must be logged on to insert runner data.
Users must be members of the Admin role to edit or delete runner data.
There are no security requirements for viewing runner data.
You need to protect the application against cross-site request forgery.
Passwords are hashed by using the SHA1 algorithm.
RunnerLog.Providers.RunLogRoleProvider.cs contains a custom role provider.
Relevant portions of the application files follow. (Line numbers are included for reference only.)
3.5.3 Question
Multiple Choices
You are adding the capability for users to customize their site’s display colors. You are required to provide a slider that enables users to change each RGB element.
What can you do to ensure that this gets treated in the model and stored in the database as a single RGB color? (Choose all that apply.)
A. Strongly bind the sliders to their own individual fields in the model. Ensure that the model unit for color only implements the GET, where you write code that concatenates the values.
B. Create a custom model binder that knows to look for the three values and how to put them together to get the single color.
C. Add the three different elements to the model and ensure that your update statement to the database correctly joins the elements to get the appropriate color.
D. Create a custom model binder that evaluates the entire color customization process and binds the entire model rather than just managing a subset of the information.
Answer:
BD
Explanation
A. Incorrect: This does not easily enable saving into the database because the color itself only implements the HTTP Get.
B. Correct: This solution works because it combines the three discrete values into a single object on the model.
C. Incorrect: Although this solution gets the value into the database appropriately, it does not fulfill the requirement that the model be able to use the color as a single value.
D. Correct: Although it takes more work, using an approach of creating a model binder for the entire object, rather than just a part, successfully manages the need to have it in the model and in the database.