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. Configure Authentication:  The WebAPI project type used in assignment 1 does not support individual user accounts. In this step you will modify your project to use them. Steps:
    1. Make a backup copy of your project source files. You will be making substantial changes and should have a backup.
    2. Open your source files in Windows Explorer and replace your files with the files in Authentication.zip. The App_Start folder can be completely replaced. (note: do not delete files from your project that are not in the zip file).
    3. Open your project in Visual Studio. Click the icon "Show All Files" at the top of Solution Explorer. Look through your project for files that are excluded (they will have gray icons), right-click on them and select "Include in Project."
    4. If your project name not "mis424Assignments" you need to replace all instances of "mis424Assignments" with the name of your project. Use VS's replace feature with settings "entire solution", and "case sensiitive".  
    5. Delete the two folders "Providers" and "Results."
    6. web.config: Make sure the connection string "DefaultConnection" is not commented out.
    7. Decorate a controller with the [Authorize] filter as described in Assignment 2, exercise 2, steps b & c. Test. You should be prompted for authentication.
  2. 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 any other 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. 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 query into the DataReposiory.
    6. Controller: Add an action method for _leftMenu that retrieves a list of categories.
    7. 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).
  3. 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));
              }
  4. 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.
  5. 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
Top