300583 Web Systems Development
PRACTICAL SET 3 DUE: 8PM 25 JAN 2019
In this Practical Set, you will implement a roughly full-fledged website for the "Gourmet Pizza" shop
with features such as authentication, full interactions with database, etc.
Steps for completing this practical set
1. Since we are going to include authentication in this project, you need to create a brand-new
ASP.NET Core MVC project called "GourmetPizzaPrac3" with Visual Studio. You should
follow the steps in Lecture 11 to have the Identity package in your project, and then change
the database provider to Sqlite, and then apply the initial migration.
2. Modify the Home page of your project to suit the "Gourmet Pizza" shop. To achieve this, you
should repeat the Steps 5, 7, and 13 from Prac1.
3. Create the following three Model classes: Pizza, Customer and Purchase, and establish the
one-to-many relationship between Pizza and Purchase, and the one-to-many relationship
between Customer and Purchase with navigation properties.
a. Pizza: the definition of this class should include that in Prac1 with the addition of
necessary navigation properties.
b. Customer: the definition of this class should be similar to that in Prac2 with the
following two exceptions:
i. There is no ‘ID‘ property in this class; instead, the ‘Email‘ property is used as
the primary key for this class.
ii. It should include necessary navigation properties.
c. Purchase: the definition of this class should include the following properties and their
associated requirements:
Property Data Type Requirement
ID int Primary key;
PizzaID int Foreign Key (NB: since the name follows convention, this
will be automatically figured out by EF Core)
CustomerEmail string Same as above;
PizzaCount int The number of pizzas purchased. Should range from 1 to 80.
TotalCost decimal The total cost of this purchase. Should range from 1.00 to
1000.00
ThePizza Pizza This is a navigation property
TheCustomer Customer Same as above
4. Use scaffolding to create the controllers and views for all the three Model classes above.
5. Use migration to create the database tables for all the three Model classes above.
6. Follow Lecture 11 slides to implement a ‘My Details‘ page to allow a logged-in customer to
enter and update his/her details.
Page 2 of 3
7. Follow Lecture 11 slides to redirect a newly-registered customer to the ‘My Details‘ link.
8. Modify the Create() method in the PurchasesController and its associated view to implement
a customized page for a logged-in customer to purchase pizzas. Specifically, you should
implement the following:
a. The web form for purchasing pizzas should include the following input devices:
i. A dropdown list for selecting pizzas. The options in this dropdown list should
be read from the database, and each option should use a pizza‘s ID as its
value and a pizza‘s Name as its text.
ii. An <input> field for entering PizzaCount. The PizzaCount should range from
1 to 80.
b. If the customer inputs in this web form are valid, insert this purchase into the
database. Note that you should do the following before the insertion:
i. Get the CustomerEmail for this purchase. (Hint: see the ‘My Details‘
implementation in the sample project for Lecture 11).
ii. Calculate the TotalCost for this purchase.
c. Display a confirmation message for this purchase if it is successful. The message
should include the following pieces of info: the name and the number of the pizza
ordered, and the total cost.
Hint: Lecture 8 slides and sample project have been updated to guide you in implementing
this step. Please download the latest versions of Lecture 8 slides and sample project, and refer to
the last section of the slides.
9. Modify the Index() method in the PurchasesController and its associated view to implement
the following:
a. Only display the purchases made by the logged-in customer. (Hint: this can be done
by calling the Where() method with a lambda expression on CustomerEmail).
b. Remove the ‘Edit‘, ‘Details‘ and ‘Delete‘ links in each row.
c. There should be a column displaying the name of the pizza purchased.
d. There should be a column displaying the full name of the customer making this
purchase.
e. The three column headings (‘Pizza name‘, ‘PizzaCount‘ and ‘TotalCost‘) should be
links that users can click to sort all records by that column.
f. Clicking a column heading toggles the display order between ascending and
descending.
10. Add a CalcPurchaseStats() action method into the PurchasesController to calculate and
display the following distribution: the number of purchases against each PizzaCount. In order
to achieve this, you also need to create relevant Views and ViewModels.
11. Make the links in the navigation bar dynamic:
a. When a customer is not logged-in, he/she should see the following links: Home,
Pizzas (pointing to /Pizzas/Index), Register, Login.
b. When a customer is logged-in, he/she should see the following links: Home, Pizzas
Index (pointing to /Pizzas/Index), My Details, Purchase Pizzas (pointing to
/Purchases/Create), My Purchases (pointing to /Purchases/Index), Statistics (pointing
to /Purchases/CalcPurchaseStats), Logout.
Hint: modifying _Layout.cshtml by following the idea of /Shared/_LoginPartial.cshtml.
Page 3 of 3
12. Use the [Authorize] attribute class to make the following links only accessible to logged-in
customers: My Details, Purchase Pizzas, My Purchases, Statistics.
Checkpoint (2 marks)
The Prac3 Checkpoint will occur in your registered practical class in week 11. At this checkpoint you
should complete steps 1-2.
Marking criteria:
Step 1: 1 mark.
Step 2: 1 mark.
Any mistake in a step will results in a zero mark for that step. No decimal mark is available.
Final Submission (16 marks)
Please follow the steps below to submit your completed Prac3 to vUWS:
Zip up the entire GourmetPizza folder and its sub-folders, which contain all your files for your
project.
Name the ZIP file Surname_studentid_Prac3.zip
Submit the zip file:
o In VUWS, go to ‘Practicals’
o Click on ‘Prac3 Submission’; this link will be made available closer to the deadline.
o Attach your zip file and submit
Marking Criteria: Please see the rubric for Prac3 in the My Grades page on vUWS.
Notes:
You can submit the zip file multiple times until the due time.
Work submitted after the due time will incur a 10% per day late penalty as per university
policy https://policies.westernsydney.edu.au/document/view.current.php?id=227
Based on the policy, the 10% above means the 10% of the worth of the assessment,
not your final score. So if the worth of the assessment is 10 marks and you scored 5
marks with a 5-day lateness, then you‘ll receive 0 mark.
因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]
微信:codinghelp
原文地址:https://www.cnblogs.com/cccccchelper/p/10335485.html