Logo
Question DetailsNormal
$ 18.00
CS 3410 Assignment #8: Database Implementation Pt. 2 | Complete Solution
Question posted by
request

CS 3410 Assignment #8: Database Implementation Pt. 2


For this assignment you will build a new set of tables that you need in order to complete the ShoppingCart website. But this time your website will not be the Fun Cake Store website anymore. It will be a website that sells a different set of products that you come up with.
This time your website will also include a "Check-Out" tab which will require the user to fill in a Customer account form. After filling that out (which is an activity like filling out the form of payment information on a real shopping cart website) the data will be saved to the appropriate table, and the user will be given a summation of their purchase. And your website will also include an "Admin" tab where you can log in and review a list of all completed purchases.
For this assignment, you will be using a new zipped template file with the additional C# code in it for your website's new functionality. To get started, download the ShoppingCartV2.zip archived project folder. Unzip the file and place the ShoppingCartV2 folder into your Projects folder inside of your Visual Studio 2015 folder.
Once you have done that, you can start up Visual Studio 2015, and then go to the File menu, and choose "Open" and then "Project/Solution", and then find the ShoppingCartV2 folder, and open it, and then select the "ShoppingCartV2.sln" file you will see inside another ShoppingCartV2 folder, and then click on the "Open" button to open up your ShoppingCartV2 website project.
Once again, you will start off by creating your ShoppingCartDB database:
________________________________________
Creating the ShoppingCartDB Database
1.    To create the database, right-click on the "App_Data" folder in the Solution Explorer and select Add and then New Item, and then click on Data and SQL Server Database, and place ShoppingCartDB.mdf in the Name field:
 
2.    When it is created, you should see your Database in the Server Explorer. If you click on the triangle next to its name you will see the word "Tables" in a list of resources in the database.
 
________________________________________
Next, you need to create the following set of Tables (unfortunately you have to re-create your Customers and Products table from the last assignment):
•    Customers
•    Products
•    Options
•    Intersections
•    PurchaseOrders
•    LineItems
•    OptionAssociations
After creating these Tables, you will be shown how to populate the tables with data for your new set of products, and you will be given code that will act as the Controller and the Views to manage the data and the user interactions with the data.
________________________________________
Creating the Customers Table
1.    To create the Customers table right-click on the Tables folder and select "Add New Table". When you do this, you will see a "Loading..." message show up:
 
After this, you should see a Table with just one "Id" field, like so:
 
2.    Change the "Id" field's name to "ID", or in other words just capitalize the "d". Next you will create the following fields in this table, and notice that the ID field is the only one that has a key next to it, making it the Primary Key. It is also the only one that is an "int" field. The others are "nvarchar" fields (which is a type of text field) with different values in the parentheses representing the maximum number of characters accepted in those fields.
Be careful to make sure you spell each field as you see it here (names are case-sensitive) and be sure to put in the exact same value in the parentheses that you see here, and be sure that you have "Allow Nulls" selected for only the ones shown here:
 
3.    Click on that first field again, the ID field. Then look into the Properties window and scroll down to the "Identity Specification" property. Open up that property by clicking on the little plus sign next to it, and then click on the "(Is Identity)" option, and set that to "True" like so:
 
4.    Now you will give your Table and the name Customers. To do this, look into the space in the middle of the screen right below the fields, where you will see the following line:
      CREATE TABLE [dbo].[Table]
On that line, highlight the word "Table" that is inside the to square brackets [ ] like so:
 
Now change the highlighted word from "Table" to "Customers" like so:
 
5.    Next, click on the word "Update" that is next to an up-arrow on a line that is right above all the fields you added and right above the "Name" column that is above those fields:
 
When you click on that "Update", you should the following screen pop up:
 
6.    Next, click on the "Update Database" button. After that is done your table doesn't show up right away in your "Tables" list on the left, because you must refresh that list. To refresh that list, right-click on the "Tables" item on the left and select "Refresh" like so:
 
After doing that you should see the Customers table show up under the "Tables" item if you open up that item:
 
7.    Next, you will create a new Model for your table. This step creates the documents necessary to link your table to your C# code. If you do not do this step correctly, your program will not work even if your table is correct. So be sure to follow these steps carefully.
You create your Model by right-clicking on the Models folder in the Solution Explorer and selecting Add and then New Item. Select the "Data" Installed Template (the category on the left side) and then select the "ADO.NET Entity Data Model" option. Then, at the bottom, give your data model the name CustomersModel.edmx:
 
8.    After you click the Add button, the Entity Data Model Wizard appears, and under the line "What should the model contain?" select the "EF Designer from database" or if that option is not there, then select the "Generate from database" option.
 
9.    Then in the next screen, in the drop-down box under the line "Which data connection should your application use to connnect to the database?", choose ShoppingCartDB.mdf, and note that the "entity connection settings" shown at the bottom should say "ShoppingCartDBEntities".
 
10.    Next, you might see the following screen that asks you to choose the version of the Entity Framework that you want to use. If you don't see this screen, don't worry, but if you do see this screen, then select "Enity Framework 5.0" like so:
 
11.    After you click the Next button, you will go to the "Choose Your Database Objects and Settings" screen, where you must expand the "Tables" node, and then the "dbo" node, and then select the Customers table:
 
12.    After you click on the Finish button, you might see the following screen that warns you about unsafe templates. If you don't see this screen, don't worry, but if you do see this screen, it may show up a couple of times during this process, but don't worry, this template is safe, so click on the "OK" button each time you see it:
 
13.    Next, you will see the following image of a Customer record for your new table, and you will have a CustomersModel.edmx file in your Models folder.
 
Next, click on the "X" on the current tab to close this tab, which shows the above CustormersModel.edmx record, and if you are asked if you want to save the changes, answer "Yes".
Now you are finished creating the Customers table.
________________________________________
Creating the Products Table
1.    To create the Products table, once again right click on the Tables folder and select "Add New Table". Next, create the following fields that are shown below in this table, following similar steps as those that you did in created the "Customers" table. And notice that the ProductID field is the Primary Key this time, and just like before, it is an "Identity Specification" field, so you need to take the steps necessary to set that. And also note that only the ProductName field and the ImageFile field are marked as "Allow Nulls":
 
 
2.    Next, follow the directions given above to save the table with the name "Products" in the same way you saved and named the last table.
3.    After that, you will create a new Model for your table by right-clicking on the Models folder in the Solution Explorer and selecting Add and then New Item. Select the Data category and select the ADO.NET Entity Data Model template. Then give your data model the name ProductsModel.edmx:
 
4.    After you click the Add button, the Entity Data Model Wizard appears, and under the line "What should the model contain?" select the "EF Designer from database" or if that option is not there, then select the "Generate from database" option.
 
5.    Then in the next screen, in the drop-down box under the line "Which data connection should your application use to connnect to the database?", choose ShoppingCartDBEntities this time (or ShoppingCartDB.mdf if that is shown) and note that the "entity connection settings" shown at the bottom should say "ShoppingCartDBEntities1". If you don't see a "1", take special note of the number you do see because you will need to use that number later.
 
6.    Next, you might see the following screen that asks you to choose the version of the Entity Framework that you want to use. If you don't see this screen, don't worry, but if you do see this screen, then select "Enity Framework 5.0" like so:
 
7.    After you click the Next button, you will go to the "Choose Your Database Objects" screen, where you must expand the Tables node, and select the Products table only, and not the other table:
 
8.    After you click on the Finish button, you might see the following screen that warns you about unsafe templates. If you don't see this screen, don't worry, but if you do see this screen, it may show up a couple of times during this process, but don't worry, this template is safe, so click on the "OK" button each time you see it:
 
9.    Next, you will see the following image of a Product record for your new table, and you will have a ProductsModel.edmx file in your Models folder.
 
10.    Next, click on the "X" on the current tab to close this tab, which shows the above ProductsModel.edmx record, and if you are asked if you want to save the changes, answer "Yes".
Now you are finished creating the Products table.
________________________________________
Creating the Options Table
1.    To create the Options table, once again right click on the Tables folder and select "Add New Table". Next, create the following fields that are shown below in this table, following similar steps as those that you did in created the last tables. And notice that the OptionID field is the Primary Key this time, and it is an "Identity Specification" field, so you need to take the steps necessary to set that. And also note that no fields "Allow Nulls" this time:
 
 
2.    Next, follow the directions given above to save the table with the name "Options" in the same way you saved and named the last two tables.
3.    Next, you will create a new Model for your table by right-clicking on the Models folder in the Solution Explorer and selecting Add and then New Item. Select the Data category and select the ADO.NET Entity Data Model template. Then give your data model the name OptionsModel.edmx:
 
4.    After you click the Add button, the Entity Data Model Wizard appears, and under the line "What should the model contain?" select the "EF Designer from database" or if that option is not there, then select the "Generate from database" option.
 
5.    Then in the next screen, in the drop-down box under the line "Which data connection should your application use to connnect to the database?", choose ShoppingCartDBEntities (with some number) this time (or ShoppingCartDB.mdf if that is shown) and note that the "entity connection settings" shown at the bottom should say "ShoppingCartDBEntities2". If you don't see a "2", take special note of the number you do see because you will need to use that number later.
 
6.    Next, you might see the following screen that asks you to choose the version of the Entity Framework that you want to use. If you don't see this screen, don't worry, but if you do see this screen, then select "Enity Framework 5.0" like so:
 
7.    After you click the Next button, you will go to the "Choose Your Database Objects" screen, where you must expand the Tables node, and select the Options table only, and not the other tables:
 
8.    After you click on the Finish button, you might see the following screen that warns you about unsafe templates. If you don't see this screen, don't worry, but if you do see this screen, it may show up a couple of times during this process, but don't worry, this template is safe, so click on the "OK" button each time you see it:
 
9.    Next, you will see the following image of a Option record for your new table, and you will have a OptionsModel.edmx file in your Models folder.
 
10.    Next, click on the "X" on the current tab to close this tab, which shows the above OptionsModel.edmx record, and if you are asked if you want to save the changes, answer "Yes".
Now you are finished creating the Options table.
________________________________________
Creating the Intersections Table
________________________________________
1.    To create the Intersections table, once again right click on the Tables folder and select "Add New Table". Next, you will create only two fields for this table, both of which are "int" fields, and both of which together make up the primary key. And neither field allows null. The names of the two fields are ProductID and OptionID.
In order to make BOTH fields the primary key, you have to select them both at the same time, then right click on them and choose "Set Primary Key" like so:
 
After doing that, you should see a key next to both fields, like so:
 
Note that neither of these two fields is an "Identity Specification" field, so you don't have to change the value of that property:
 
2.    Next, follow the directions given above to save this table with the name "Intersections" in the same way you saved and named the last three tables.
3.    After that, you will create a new Model for your table by right-clicking on the Models folder in the Solution Explorer and selecting Add and then New Item. Select the Data category and select the ADO.NET Entity Data Model template. Then give your data model the name IntersectionsModel.edmx:
 
4.    After you click the Add button, the Entity Data Model Wizard appears, and under the line "What should the model contain?" select the "EF Designer from database" or if that option is not there, then select the "Generate from database" option.
 
5.    Then in the next screen, in the drop-down box under the line "Which data connection should your application use to connnect to the database?", choose ShoppingCartDBEntities (with some number) this time (or ShoppingCartDB.mdf if that is shown) and note that the "entity connection settings" shown at the bottom should say "ShoppingCartDBEntities3". If you don't see a "3", take special note of the number you do see because you will need to use that number later.
 
6.    Next, you might see the following screen that asks you to choose the version of the Entity Framework that you want to use. If you don't see this screen, don't worry, but if you do see this screen, then select "Enity Framework 5.0" like so:
 
7.    After you click the Next button, you will go to the "Choose Your Database Objects" screen, where you must expand the Tables node, and select the Intersections table only, and not the other tables:
 
8.    After you click on the Finish button, you might see the following screen that warns you about unsafe templates. If you don't see this screen, don't worry, but if you do see this screen, it may show up a couple of times during this process, but don't worry, this template is safe, so click on the "OK" button each time you see it:
 
9.    Next, you will see the following image of a Intersection record for your new table, and you will have a IntersectionsModel.edmx file in your Models folder.
 
10.    Next, click on the "X" on the current tab to close this tab, which shows the above IntersectionsModel.edmx record, and if you are asked if you want to save the changes, answer "Yes".
Now you are finished creating the Intersections table.
________________________________________
Creating the PurchaseOrders Table
________________________________________
1.    To create the PurchaseOrders table, once again right click on the Tables folder and select "Add New Table". Next, create the following fields that are shown below in this table, following similar steps as those that you did in creating the other tables. And notice that the OrderID field is the Primary Key this time, and it is an "Identity Specification" field, so you need to take the steps necessary to set that. And also note that none of the fields are marked as "Allow Nulls":
 
 
2.    Next, follow the directions given above to save the table with the name "PurchaseOrders" in the same way you saved and named the other tables.
3.    After that, you will create a new Model for your table by right-clicking on the Models folder in the Solution Explorer and selecting Add and then New Item. Select the Data category and select the ADO.NET Entity Data Model template. Then give your data model the name PurchaseOrdersModel.edmx:
 
4.    After you click the Add button, the Entity Data Model Wizard appears, and under the line "What should the model contain?" select the "EF Designer from database" or if that option is not there, then select the "Generate from database" option.
 
5.    Then in the next screen, in the drop-down box under the line "Which data connection should your application use to connnect to the database?", choose ShoppingCartDBEntities (with some number) this time (or ShoppingCartDB.mdf if that is shown) and note that the "entity connection settings" shown at the bottom should say "ShoppingCartDBEntities4". If you don't see a "4", take special note of the number you do see because you will need to use that number later.
 
6.    Next, you might see the following screen that asks you to choose the version of the Entity Framework that you want to use. If you don't see this screen, don't worry, but if you do see this screen, then select "Enity Framework 5.0" like so:
 
7.    After you click the Next button, you will go to the "Choose Your Database Objects" screen, where you must expand the Tables node, and select the PurchaseOrders table only, and not the other tables:
 
8.    After you click on the Finish button, you might see the following screen that warns you about unsafe templates. If you don't see this screen, don't worry, but if you do see this screen, it may show up a couple of times during this process, but don't worry, this template is safe, so click on the "OK" button each time you see it:
 
9.    Next, you will see the following image of a PurchaseOrder record for your new table, and you will have a PurchaseOrdersModel.edmx file in your Models folder.
 
10.    Next, click on the "X" on the current tab to close this tab, which shows the above PurchaseOrdersModel.edmx record, and if you are asked if you want to save the changes, answer "Yes".
Now you are finished creating the PurchaseOrders table.
________________________________________
Creating the LineItems Table
________________________________________
1.    To create the LineItems table, once again right click on the Tables folder and select "Add New Table". Next, you will create the five fields shown below, but once again, the first two fields for this table will together make up the primary key.
In order to make BOTH the OrderID field and the LineNumber field the primary key, you have to select them both at the same time, then right click on them and choose "Set Primary Key": After doing that, you should see a key next to both fields, like so:
 
Note that none of the fields in this table will "Allow Nulls", and also note that neither of these two primary key fields is an "Identity Specification" field, so you don't have to change the value of that property:
 
2.    Next, follow the directions given above to save this table with the name "LineItems" in the same way you saved and named the other tables.
3.    After that, you will create a new Model for your table by right-clicking on the Models folder in the Solution Explorer and selecting Add and then New Item. Select the Data category and select the ADO.NET Entity Data Model template. Then give your data model the name LineItemsModel.edmx:
 
4.    After you click the Add button, the Entity Data Model Wizard appears, and under the line "What should the model contain?" select the "EF Designer from database" or if that option is not there, then select the "Generate from database" option.
 
5.    Then in the next screen, in the drop-down box under the line "Which data connection should your application use to connnect to the database?", choose ShoppingCartDBEntities (with some number) this time (or ShoppingCartDB.mdf if that is shown) and note that the "entity connection settings" shown at the bottom should say "ShoppingCartDBEntities5". If you don't see a "5", take special note of the number you do see because you will need to use that number later.
 
6.    Next, you might see the following screen that asks you to choose the version of the Entity Framework that you want to use. If you don't see this screen, don't worry, but if you do see this screen, then select "Enity Framework 5.0" like so:
 
7.    After you click the Next button, you will go to the "Choose Your Database Objects" screen, where you must expand the Tables node, and select the LineItems table only, and not the other tables:
 
8.    After you click on the Finish button, you might see the following screen that warns you about unsafe templates. If you don't see this screen, don't worry, but if you do see this screen, it may show up a couple of times during this process, but don't worry, this template is safe, so click on the "OK" button each time you see it:
 
9.    Next, you will see the following image of a LineItem record for your new table, and you will have a LineItemsModel.edmx file in your Models folder.
 
10.    Next, click on the "X" on the current tab to close this tab, which shows the above LineItemsModel.edmx record, and if you are asked if you want to save the changes, answer "Yes".
Now you are finished creating the LineItems table.
________________________________________
Creating the OptionAssociations Table
________________________________________
1.    To create the OptionAssociations table, once again right click on the Tables folder and select "Add New Table". Next, you will create only three fields for this table, all of which are "int" fields, and all of which together make up the primary key. None of the fields allows nulls. The names of the three fields are OrderID, ProductID and OptionID.
In order to make ALL THREE fields the primary key, you have to select them all at the same time, then right click on them and choose "Set Primary Key" like so:
 
After doing that, you should see a key next to all three fields, like so:
 
Note that none of these three fields is an "Identity Specification" field, so you don't have to change the value of that property:
 
2.    Next, follow the directions given above to save this table with the name "OptionAssociations" in the same way you saved and named the other tables.
3.    After that, you will create a new Model for your table by right-clicking on the Models folder in the Solution Explorer and selecting Add and then New Item. Select the Data category and select the ADO.NET Entity Data Model template. Then give your data model the name OptionAssociationsModel.edmx:
 
4.    After you click the Add button, the Entity Data Model Wizard appears, and under the line "What should the model contain?" select the "EF Designer from database" or if that option is not there, then select the "Generate from database" option.
 
5.    Then in the next screen, in the drop-down box under the line "Which data connection should your application use to connnect to the database?", choose ShoppingCartDBEntities (with some number) this time (or ShoppingCartDB.mdf if that is shown) and note that the "entity connection settings" shown at the bottom should say "ShoppingCartDBEntities6". If you don't see a "6", take special note of the number you do see because you will need to use that number later.
 
6.    Next, you might see the following screen that asks you to choose the version of the Entity Framework that you want to use. If you don't see this screen, don't worry, but if you do see this screen, then select "Enity Framework 5.0" like so:
 
7.    After you click the Next button, you will go to the "Choose Your Database Objects" screen, where you must expand the Tables node, and select the OptionAssociations table only, and not the other tables:
 
8.    After you click on the Finish button, you might see the following screen that warns you about unsafe templates. If you don't see this screen, don't worry, but if you do see this screen, it may show up a couple of times during this process, but don't worry, this template is safe, so click on the "OK" button each time you see it:
 
9.    Next, you will see the following image of a OptionAssociation record for your new table, and you will have a OptionAssociationsModel.edmx file in your Models folder.
 
10.    Next, click on the "X" on the current tab to close this tab, which shows the above OptionAssociationsModel.edmx record, and if you are asked if you want to save the changes, answer "Yes".
Now you are finished creating the OptionAssociations table.
________________________________________
If you ran into a problem with any of your Entity names when you were creating your table models, you will have to take an extra step. All of the Entity names (except the first one which is "ShoppingCartDBEntities") should end with a number, either "ShoppingCartDBEntities1", "ShoppingCartDBEntities2", "ShoppingCartDBEntities3", "ShoppingCartDBEntities4", "ShoppingCartDBEntities5", or "ShoppingCartDBEntities6". But if you ran into a problem and had to create an Entity model multiple times, the number associated with that model may have increased each time. That means your numbers may be off. For example if this happened while you were creating "ShoppingCartDBEntities4", then it may have become "5", and "5" may have become "6", and "6 may have become "7". If this did happen, you will have to determine which numbers are off, and then you need to go into your Controllers folder in the Solution Explorer, and then double-click on the PartialCode.cs file to open it up.
If any of your numbers are off, you will have to change the Entity names for those values in the PartialCode.cs file. Search for the Entity names that you know are off, starting with the highest numbers first and fix them one by one. For example if "4", "5" and "6" became "5", "6" and "7" as described above, first change everywhere you see "ShoppingCartDBEntities6" to "ShoppingCartDBEntities7" (there will be more than one of these), and then change everywhere you see "ShoppingCartDBEntities5" to "ShoppingCartDBEntities6" (there will be more than one of these), and then change everywhere you see "ShoppingCartDBEntities4" to "ShoppingCartDBEntities5" (there will be more than one of these). When you are all done, save and close this file.
________________________________________
After you have created your new tables, you should have seven tables in all listed here in alphabetical order:
•    Customers
•    Intersections
•    LineItems
•    OptionAssociations
•    Options
•    Products
•    PurchaseOrders
Some of these tables have foreign keys in them, so the next thing you must do is set up the foreign key relationships as follows:
________________________________________
•    In the Intersections table the ProductID field is a foreign key to the same field in the Products table. And in the same Intersections table the OptionID field is a foreign key to the same field in the Options table.
________________________________________
1.    To create these foreign key relationships, right click on the Intersections table and open its "Table Definition". Then right click on the "Foreign Keys" listing in the middle section on the right, and select "Add New Foreign Key" like so:
 
2.    After that you should see the text "FK_Intersections_ToTable" show up below the "Foreign Keys" listing like so:
 
To proceed with this just hit return and the SQL command to create the Foreign Key relationship will show up as the last line in the bottom area of the middle section (which is the T-SQL window) like so:
 
3.    Next, you need to fill in the information that is underlined in red. In the "Column" entry, put "ProductID". And in the "ToTable" entry, put "Products". And in the "ToTableColumn" entry, put "ProductID" again. Once you have done that you should now see:
 
4.    To complete this SQL command, you need to add the words ON DELETE CASCADE to the end of this line so that if a Product is deleted, the records in this table that refer to that item's ProductID will also be deleted. When you have done that, you should have the following command:
 
5.    This is just one of the Foreign Keys you have to set up for this table. In order to set up the other one, right click again on the "Foreign Keys" listing in the middle section on the right, and select "Add New Foreign Key" again like so:
 
6.    After that you should see the text "FK_Intersections_ToTable_1" show up below the "Foreign Keys" listing like so:
 
To proceed with this just hit return and the SQL command to create the second Foreign Key relationship will show up in the T-SQL window like so:
 
7.    Once again, you have to complete this SQL command by filling in the information that is underlined in red. In the "Column" entry, put "OptionID". And in the "ToTable" entry, put "Options". And in the "ToTableColumn" entry, put "OptionID" again. Once you have done that you should now see:
 
8.    Then, to complete this SQL command, you need to add the words ON DELETE CASCADE to the end of this line so that if an Option is deleted, the records in this table that refer to that item's OptionID will also be deleted. When you have done that, you should have the following command:
 
9.    Next, to finish setting up these Foreign Key relationships, just click on the "Update" box above, and then click on the Update Database button in the next window that pops up.
After the update has finished, you are done with setting up your first set of Foreign Key relationships.
________________________________________
•    In the LineItems table the OrderID field is a foreign key to the same field in the PurchaseOrders table. And in the same LineItems table the ProductID field is a foreign key to the same field in the Products table.
To implement these Foreign Key relationships, follow steps similar to those that you followed to implement the above Foreign Key relationships. When you have done that you should end up with the following as the last two SQL commands:
 
________________________________________
•    In the OptionAssociations table the OrderID field is a foreign key to the same field in the PurchaseOrders table. And in the same OptionAssociations table the ProductID field is a foreign key to the same field in the Products table. And in the same OptionAssociations table the OptionID field is a foreign key to the same field in the Options table.
To implement these Foreign Key relationships, follow steps similar to those that you followed to implement the Foreign Key relationships above. When you have done that you should end up with the following as the last three SQL commands:
 
________________________________________
•    In the PurchaseOrders table the CustomerID field is a foreign key to the ID field in the Customers table.
To implement this Foreign Key relationships, follow steps similar to those that you followed to implement the Foreign Key relationships above, but be careful to match the CustomerID field to the Customers table's ID field, instead of to a field with the same name. This time your SQL command that will create this Foreign Key relationship will look like so:
 
________________________________________
The next thing you should do is go to the "View" menu and select the Error List window, so that it shows at the bottom. Then, go to the "Build" menu and choose "Build Solution". This is an important step because it validates that you have done everything correct up to this point. If you have not done everything correctly, you will see some error messages in your Error List window at this point. If you do see error messages, you must resolve them before moving on.
________________________________________
Next, you need to put your product data inside your Products table. The data inside your Products table must identify the "ProductType" (which is the same as the Tab/View name the product will appear in), the "ProductName", the "ImageFile" name, the "UnitPrice", the "MaxAmount" and the "DefaultAmount" for each product item. When dealing with cakes, the following is what your Products table looked like, but this time it should be different because you are not dealing with cake products:
 
Remember that your Products table should not be the same as the above Products table data because your products should not be cake products.
________________________________________
The Options table list a set of options that your products offer that can either increase the price (if they are accessories) or decrease the price (if they are discounts).
For instance, on the Fun Cake Store website, the first tab had 3 different Cakes that could be ordered and their product IDs were 1, 2 and 3. If an Options table existed for the Fun Cake Store website, it might have the following data:
 
This data lists 2 optional accessories for cakes, the first of which is to "Personalize With Name" your cake for an additional $1.99, and the second of which is to add "Extra Frosting" for an additional $0.99. The data also list 3 optional discounts for cakes. The "No Frosting" discount takes $1.00 off of the price, and the "Have Coupon" discount takes $0.50 off the price, and the "Member Discount" takes $1.00 off of the price.
After you have determined the options you have available in your Options table, you need to decide which products will be associated with which options. You make these associations in your Intersections table. Your Intersections table specifies which products go with which options. For instance, with the above Options table data, you might have the following Intersections table data:
 
This table data links the first cake product with the first 2 optional accessories, and it also links the second cake product with the first 2 optional accessories. Then it links the third cake product with the 3 optional discounts.
Now it is time for you to decide what options you are going to make available for your products, and then fill in the appropriate data into your Options and Intersections table to implement the accessories and discounts you want to add for your products.
________________________________________
Now you are ready to modify your HomeController.cs file. You first will need to change the siteHeading field so that your website's heading is in that field, instead of "The Fun Cake Store". Then make a similar modification to the orderHeading field to make it appropriate for the products on your website.
Then you will need to modify the tabHeadings array, the tabLabels and the optionsColumnHeading array so that they include headings and labels that describe your product categories and your option categories. For instance, you should replace the "Single Layer Options" label in the tabHeadings with the tab headings for your product, and you should replace "1-Layer" in the tabLabels with the tab labels for your product, and where you see "Single Layer Options" in the optionsColumnHeadings you should replace that with the names of the options available for your products on each tab.
Next, right below that array, there is a taxRate variable that you can leave as is, or set it to whatever value you think is appropriate:
        // The tax rate is 5%
        decimal taxRate = 0.05M;
________________________________________
Next, you need to add the .cshtml view pages (the pages with the HTML in them) for your views, along with the C# code for the other view pages for your other product tabs. The C# code for your Tab1Orders method is already in the HomeController.cs file:
________________________________________
 
________________________________________
You still need to add the code for Tab2Orders, Tab3Orders, and/or any other tabs that you are using the same way you did in the last assignment for the Fun Cake Store version of your website.
To add the .cshtml view page for each tab (starting with your "Tab1Orders" tab) right-click on that tab's method name (remember Tab1Orders is first) and then select "Add View", and then on the next screen where it says "Use a layout", click on the ellipsis button on the right:
________________________________________
 
________________________________________
Then on the next screen open the "Views" folder, and then click on the "Shared" folder, and then choose ShoppingCart2Layout.cshtml this time (NOT ShoppingCart1Layout.cshtml!), as shown here:
________________________________________
 
________________________________________
Then click on the OK button and then the Add button. When you have done this you will be taken to the newly created view page with something like the following code:
________________________________________
@{
    ViewBag.Title = "Tab1Orders";
    Layout = "~/Views/Shared/ShoppingCart2Layout.cshtml";
}

<h2>Tab1Orders</h2>
________________________________________
This code sets your view's Title, Layout and Heading. However, the Heading code uses the method name instead of using more appropriate text for the heading that is set in the "ViewBag.Message" field. To fix this problem, you need to replace the "<h2>Tab1Orders</h2>" line (the last line) with the line "<h2>@Html.Raw(ViewBag.Message)</h2>", being sure not to change the other lines. When you do this correctly, you will have the following code:
________________________________________
@{
    ViewBag.Title = "Tab1Orders";
    Layout = "~/Views/Shared/ShoppingCart2Layout.cshtml";
}

<h2>@Html.Raw(ViewBag.Message)</h2>
________________________________________
You are now finished with the Tab1Orders methods and view. After creating your Tab2Orders and Tab3Orders methods, then you will follow the same steps with those two methods to create the .cshtml view files for those views using the same above steps.
________________________________________
After finishing the above tasks, and after adding data to your tables that is appropriate for your web-store, you should be able to run your website with the Options features implemented for each tab without errors.
One of the new features in this website that you did not have in the last assignment is your Admin page. To access your Admin page you will be required to log in, and in order to log in you need to create an account for yourself. To do this, choose the "Register" link at the top of the page and then fill in the information to create an account for yourself. Note that you will have to create an account with a password of at least six characters.
When you have created the account, you should be able to click on the "Admin" view and then see that you can now access and review the contents of the following 5 tables over your website, and with the last three you can also alter their contents:
1.    Customer Accounts
2.    Purchase Orders
3.    Products Table
4.    Options Table
5.    Intersections Table
________________________________________
Now for your final two tasks, you must be sure to put a welcoming message and an image appropriate to your website on your front page by placing the code for that message and image into your Index() method near the top of your HomeController.cs.
Then, along with that, you must put a message that lists all of the users in your group on the About page by placing the code for that message into your About() method. You can use the aboutus.jpg image that has been provided for you, or if you have an image that is more appropriate, feel free to use that.
________________________________________
Now, if you have gotten everything to work, you are finally done.
________________________________________
Deliverables
There are two deliveratbles for this assignment:
1.    After completing assignment 8, Zip your ShoppingCartV1 project folder as followed :
ShoppingCartV2.zip
2.    You also need to submit a Visio of the final set of tables and relationships that make up your project, along with data types and crows feet notation.
________________________________________CS 3410 Assignment #8: Database Implementation Pt. 2


For this assignment you will build a new set of tables that you need in order to complete the ShoppingCart website. But this time your website will not be the Fun Cake Store website anymore. It will be a website that sells a different set of products that you come up with.
This time your website will also include a "Check-Out" tab which will require the user to fill in a Customer account form. After filling that out (which is an activity like filling out the form of payment information on a real shopping cart website) the data will be saved to the appropriate table, and the user will be given a summation of their purchase. And your website will also include an "Admin" tab where you can log in and review a list of all completed purchases.
For this assignment, you will be using a new zipped template file with the additional C# code in it for your website's new functionality. To get started, download the ShoppingCartV2.zip archived project folder. Unzip the file and place the ShoppingCartV2 folder into your Projects folder inside of your Visual Studio 2015 folder.
Once you have done that, you can start up Visual Studio 2015, and then go to the File menu, and choose "Open" and then "Project/Solution", and then find the ShoppingCartV2 folder, and open it, and then select the "ShoppingCartV2.sln" file you will see inside another ShoppingCartV2 folder, and then click on the "Open" button to open up your ShoppingCartV2 website project.
Once again, you will start off by creating your ShoppingCartDB database:
________________________________________
Creating the ShoppingCartDB Database
1.    To create the database, right-click on the "App_Data" folder in the Solution Explorer and select Add and then New Item, and then click on Data and SQL Server Database, and place ShoppingCartDB.mdf in the Name field:
 
2.    When it is created, you should see your Database in the Server Explorer. If you click on the triangle next to its

Available Solution
$ 18.00
CS 3410 Assignment #8: Database Implementation Pt. 2 | Complete Solution
  • This solution has not purchased yet.
  • Submitted On 15 Jan, 2018 08:07:05
Solution posted by
solution
This Solution is rated A+ previously,if yo...
Buy now to view full solution.


Other Related Solutions
closebutton

$ 629.35