Syllabus Schedule Project Canvas Assignment 1 Assignment 2 Assignment 3 Assignment 4

Assignment 3 - Retail Public Views and Stored Procedures

Modify VS's publish settings to publish "All files in project folder." This will copy your source code to the server which will aid me in providing help and with grading. In VS right-click on the project folder, select properties, Package/Publish Web, items to deploy, "All files in this project folder."

 
  1. retail/index - Listing categories: this exercise adds a layout view and category menu.
    1. All of the pages created in this assignment are public facing so their action methods should be decorated with [AllowAnonymous]. Better yet, remove all of the authorization from your project since it can make grading difficult.
    2. Layout: The retail store needs a layout view to display the header, left menu, and anyother shared elements. The tutorial Layout View describes how to setup a layout page.
    3. CSS: Add a new stylesheet named retail.css and edit App_start/BundleConfig.cs to use it.
                  bundles.Add(new StyleBundle("~/Content/css").Include(
                            "~/Content/bootstrap.css",
                            "~/Content/retail.css"));
      
      
    4. Header: You can either create a custom header or modify the default navigation. The navigation should at a minimum link to retail/index, retail/admin, and retail/about
    5. DataRepository: The category menu requires data from the database. Create a DataRepository using Dapper as described in MIS 324 assignment 4 part 3 e-f. A good name would be "RetailRepository." 
    6. Dapper needs a connection string in the web.config. Copy the LocalDB connection string from MIS 324 assignment 4 (near the bottom of the page) and add it to web.config. A good name would be "RetailStore".
    7. Sql: The sql statement for listing categories needs to join the tables Category and ProductCategory so that empty categories are not listed. The sample includes a count of items in each category which is not required. Tip: Write Sql statements using VS's query designer. It provides Intellisense and testing. When finished cut-and-paste the quiery into the DataReposiory.
    8. Controller: Add an action method for _leftMenu that retrieves a list of categories.
    9. View: Add a new view _leftMenu.cshtml. Call it from the layout page with:

      @Html.Action("_leftMenu")

      and add formatting (you may copy styles from the sample).
  2. retail/Category - This exercise creates a page that lists the products in a category.
    1. DataRepository - Add a method named GetCategoryProducts(int catID) that takes a category ID and returns the products in the category.
    2. Controller - Add a action method named Category that calls GetCategoyProducts(id).
    3. View: The index view has the appropriate layout so reuse it using this syntax:
               [AllowAnonymous]
              public ActionResult Category(int id)
              {
                  return View("index", retailRepository.GetCategoryProducts(id));
              }
  3. retail/Search - This exercise uses a stored procedure to search product titles.
    1. Left navigation: add a search textbox and button (you may copy html for the sample).
    2. Stored Procedure: Use VS Server Explorer to create a new stored procedure. The input parameter is type varchar(50). The following sql statement matches whole words starting with the query (it does not match characters in the middle of words):
           SELECT *
          from Product p
          where p.ItemName like @query + '%' or p.ItemName like '% ' + @query + '%'
          order by p.ItemName;
      
    3. DataRepository: The first example Is there a way to call a stored procedure with Dapper? shows how to call a stored procedure with Dapper.
    4. Controller: Add an action method named "Search" and populate it with product information from the stored procedure. Display the count as shown here:
         IEnumerable<Product> productList = retailRepository.Search(query);
        ViewBag.message = productList.Count() + " products match '" + query + "'" ;
      
    5. View: Reuse the index view again. Add a ViewBag to display the number of items found by the search.
    6. Controller. Also add the product count to Category.
  4. retail/about - This page describes the site features. You may copy the text from the sample or write your own.
    1. Display an image randomly selected from the database. This article shows the syntax for retrieving a single item with Dapper. The Detail view is a good template for displaying the image.

Submission instructions: Submit assignments via the Canvas course management system. Submit the full URL for each exercise in the assignment, listing the URLs in the same order that they are listed in the assignment. To minimize typos in URLs it is strongly recommended that you copy the URLs from the address bar of the browser rather than trying to type them. Incorrect URLs will not be graded and no credit will be given.

When pages are connected via navigation it is only necessary to submit the URL of the first page.

Regular Expressions HTML Color Names Color Picker ASCII Character Codes Unicode Character Codes