Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (1 vote)
214 views

MVC Specification

This document specifies the design for an ASP.NET MVC application to implement the functionality of the truYum menu items application. It defines 8 sections that describe the design requirements and technical guidelines for viewing, editing, adding to cart, and removing from cart menu items and cart functionality. The document was prepared by Seshadri M R and approved by Ramadevanahalli Lingachar and Shashidhara Murthy of the Learning Solution team.

Uploaded by

Bhargav Raju
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
214 views

MVC Specification

This document specifies the design for an ASP.NET MVC application to implement the functionality of the truYum menu items application. It defines 8 sections that describe the design requirements and technical guidelines for viewing, editing, adding to cart, and removing from cart menu items and cart functionality. The document was prepared by Seshadri M R and approved by Ramadevanahalli Lingachar and Shashidhara Murthy of the Learning Solution team.

Uploaded by

Bhargav Raju
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Cognizant Academy

truYum

ASP.NET MVC Specification Document

Version 0.1
Prepared By / Last
Reviewed By Approved By
Updated By
Selvam Ramadevanahalli
Name Seshadri M R Ramamoorthy/Abhinandan Lingachar,
Deka Shashidhara Murthy
Learning Solution Learning Solution Learning Solution
Role
Designer Architect Lead

Signature

Date

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 1 of 15


Table of Contents

1.0 Introduction 3
1.1 Purpose of this document 3
1.2 Definitions & Acronyms 3
1.3 Project Overview 3
1.4 Scope 3
1.5 Hardware and Software Requirment 3

2.0 Design for View Menu Item List Admin (TYUC001) 4


2.1 Requirement flow 4
2.2 Menu items – Admin 4
2.3 Technical guidelines 4

3.0 Design for View Menu Item List Customer (TYUC002) 7


3.1 Requirement flow 7
3.2 Menu items – Customer 8
3.3 Technical guidelines 8

4.0 Design for Edit Menu Item (TYUC003) 8


4.1 Requirement flow 8
4.2 Edit Menu Item 9

5.0 Design for Add Cart (TYUC004) 11


5.1 Requirement 11
5.2 Add to Cart 11
5.3 Technical guidelines 11

6.0 Design for View Cart (TYUC005) 12


6.1 Requirement 12
6.1 View Cart 12
6.1 No item in cart 12
6.2 Technical guidelines 13

7.0 Design for Remove Item from Cart (TYUC006) 14


7.1 Requirement 14
7.2 Remove Cart item 14
7.3 Technical guidelines 14

8.0 Standards and Guidelines 14


8.1 Controller & View 14

9.0 Change Log 15

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 2 of 15


1.0 Introduction

1.1 Purpose of this document


The purpose of this document is to define the server side implementation of the truYum
application.

1.2 Definitions & Acronyms


Definition / Acronym Description

ASP.NET Active Server Pages .NET framework created by Microsoft


used to develop and build dynamic web sites and applications.

ASP.NET MVC ASP.Net MVC is a Web development framework built on top


of ASP.Net with certain changes in the internal workings of
web page rendering

1.3 Project Overview


Refer Use Case specification document for understanding the functionality and features.

1.4 Scope
1. Creation of ASP.Net MVC web application for truYum application

1.5 Hardware and Software Requirment


1. Hardware Requirement:

a. Developer PC with 8GB RAM

2. Software Requirement

a. IE or Chrome

b. .Net Framework 4.5

c. Visual Studio Professional Edition 2015

d. SQL Server enterprise edition 2014

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 3 of 15


2.0 Design for View Menu Item List Admin
(TYUC001)

2.1 Requirement flow


Steps Explanation

1. Application user launches the application. There should be a link to View the Menu items as
the Admin of the application.

2. Create an Empty controller MenuItemsController, to contain Actions related to Menu items.

3. Use Entity Framework to get the data of the relevant entities and display it in the View.

4. Admin user would be able to view all the menu items.

5. On any exception, user should be directed to “Error” view with a message Exception
occurred in [Action] method of [controller]. Along with this, please append the
exception message.

2.2 Menu items – Admin


List the menu items for admin.

2.3 Technical guidelines


 Create class for Category with Id and Name data fields

 Use data annotation Key for the Id field

 Create the MenuItem model with the required fields and data annotations

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 4 of 15


 Use data annotation Key for the Id field

 Use data annotation Required for the Name & Price fields. This data annotation
will show the default message on the UI while creating a MenuItem.

 Use data annotation Display with name attribute for the fields, FreeDelivery and
DateOfLaunch. This will ensure that the detail listed on the UI will be appropriate.

 Use the data annotation DataType as Date for DateOfLaunch. This will help to
display the date field in the format that is expected.

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}",
ApplyFormatInEditMode = true)]

The ApplyFormatInEditMode being set to true is used to ensure that the


date is filled in correct manner in the text box

 Reference the CategoryId and the Category class reference as Foreign key in the
MenuItem class

 Create the Cart model with the required fields and data annotations. Create a reference
to the MenuItem class to create foreignkey reference

 Use data annotation Key for the Id field

 Foreign key reference

 Create truYumContext class which inherits DbContext class. Include namespace


“System.Data.Entity”

 Create a class TruYumContext in the Models folder. Inherit it from DbContext class of
the namespace System.Data.Entity

 Create a constructor of the truYumContext. Specify the name of the database


connection string element to be “ TruYumContext”

 Create a connection string in Web.Config to connect to the database with the


connection string name “TruYumContext”

 Add DbSets for MenuItems, Carts and Categories in the TruYumContext class

 Override the “OnModelCreating” method to remove the Pluralizing table names

protected override void OnModelCreating(DbModelBuilder modelBuilder)


{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}

The “OnModelCreating” method override ensures that the table that gets created
thru the CodeFirst approach has a singular name. On
o Enabling migration
o Add migration
o Update database

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 5 of 15


By default, there will be DbSet of MenuItems, Carts based on which the
EntityFramework will create a table with the name “MenuItems” &
“Carts”. The OnModelCreating override will create tables with singular name

 On completion of “Update database” please insert master data in “Categories”


table in the database. Master data should be

o Main Course

o Starters

o Snack

 Modify the _Layout file to point to the Home page link

 Modify the RouteConfig for the Default route to point to the MenuItems controller

 Create Hyperlink for MenuItems listing for Admin and Customer

o In the ActionLink for Menu Item for Admin “Menu Item – Admin”, send an object with
a parameter “isAdmin” whose value should be True, to be output as querystring
parameter. This will NOT be required for Customer role

 Create Hyperlink for Customer for Cart listing

 Create MenuItemsController thru EntityFramework scaffolding. Use the Index action method
to list the Menu items

o Create a boolean parameter “isAdmin” to the Index method and set the default value
to false. This would be used to filter the menu item listing for Admin and Customer

 The “Create New” link in the menu item list page should be used to Create a new Menu Item
by the admin user.

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 6 of 15


 Create a View “Error” which should be accessible from anywhere. This view should access
error message from TempData to display on the UI

3.0 Design for View Menu Item List Customer


(TYUC002)

3.1 Requirement flow


Steps Explanation

1. Application user launches the application. There should be a link to View the Menu items as
the Customer of the application.

2. Customer user would be able to view the Active menu items and whose date of launch is in

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 7 of 15


the past compared to current date.

3. On any exception, user should be directed to “Error” view with a message Exception
occurred in [Action] method of [controller]. Along with this, please append the
exception message.

3.2 Menu items – Customer


List the menu items for customer.

3.3 Technical guidelines


 The link added in _Layout is to load the menu items for the customer role user

 Modify the Index Action method of MenuItemsController to filter the Menu items as per the
requirement

 Set the isAdmin value in ViewBag

 Modify the Index view to access the ViewBag to choose the columns to be listed

 Use the ViewBag data to toggle the Action column hyperlink

4.0 Design for Edit Menu Item (TYUC003)

4.1 Requirement flow


Steps Explanation

1. This feature is available for Admin user only

2. Admin user clicks on Edit link against every line item in the Menu items list. On click the edit
page loads

3. The menu item Id should be sent to the Edit Action method of the MenuItemsController

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 8 of 15


4. Ensure that the Category data is sent in ViewBag to be used to list in the dropdown. This
should be used to set the data source to the DropDownList thru HTMLHelper

5. On editing the data, use Entity Framework to update the data

6. On any exception, user should be directed to “Error” view with a message Exception
occurred in [Action] method of [controller]. Along with this, please append the
exception message.

4.2 Edit Menu Item


Explanation steps are not included for the above diagram as well as subsequent sample snapshots.
Earlier explanation steps can be referred to arrive at the understanding.

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 9 of 15


 On clicking the “Save” button, the data should be updated in database.

 The “Back to List” hyperlink should navigate to the MenuItem listing page. The role of the user
should be set while redirecting to Menu item list.

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 10 of 15


5.0 Design for Add Cart (TYUC004)

5.1 Requirement
Steps Explanation

1. Customer clicks on “Add to Cart” link on a menu item from Menu Item List.

2. Customer is redirected to View Cart Url /Cart/AddToCart?menuItemId=3. Here 3 is the id of


the chosen menu item id

3. The menu item should be added to the Cart table for the customer

4. On any exception, user should be directed to “Error” view with a message Exception
occurred in [Action] method of [controller]. Along with this, please append the
exception message.

5.2 Add to Cart

5.3 Technical guidelines


 Use Entity Framework to add an entity to Cart table.

 Set the UserId to 1, a hardcoded value

 Set the menuItemId to the querystring parameter

 On adding an item to cart, redirect the user to View the items in cart

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 11 of 15


6.0 Design for View Cart (TYUC005)

6.1 Requirement
Steps Explanation

1. Customer clicks on “Cart” link on the navigation bar.

2. Customer gets directed to the Url /Cart or /Cart/Index

3. Set variable userId with type int having value 1

4. Get all the cart items of the user and show the menu item detail

5. If there are no cart items, then display a message and a link to View menu items to add to
cart. This should direct the Customer to the Menu item list with a link to add the item to cart.

6. On any exception, user should be directed to “Error” view with a message Exception
occurred in [Action] method of [controller]. Along with this, please append the
exception message.

6.1 View Cart

6.1 No item in cart

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 12 of 15


6.2 Technical guidelines
 Create CartController as an empty MVC controller

 Create Index action method to Get the cart items for the user whose Id is 1, a hardcoded
value

 Include “System.Data.Entity” namespace

 Use Entity Framework’s Include feature to get the MenuItem detail, to get its data included
with Cart detail

 Create a View for the menu item detail listing. Have link in each row to “Remove” item
from cart. Bind the cart id to the link

 Use MVC Razor syntax in the View to check if the bound model contain data or not. If
there is no data display textual content stating “There are no items in your cart.” Provide
a link “View Menu Items” aiding the customer to navigate to Menu items page. This page
has a link to add the item to cart.

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 13 of 15


7.0 Design for Remove Item from Cart
(TYUC006)

7.1 Requirement
Steps Explanation

1. Customer clicks on “Remove” link on menu item in the Cart listed thru /Cart or
/Cart/Index.

2. On clicking the “Remove” link, the entity in Cart gets removed

3. Customer gets directed to the View cart page

7.2 Remove Cart item

7.3 Technical guidelines


 The View cart list has the Id bound to the “Remove” link

 Identify the Cart item from the Carts entity

 Delete the item and Save changes for the action to be updated in the database

8.0 Standards and Guidelines

8.1 Controller & View


1. Action methods should have a meaningful name

2. Remove unused Action methods

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 14 of 15


3. Use try catch blocks to catch exceptions

4. There should not be any hard coded values in code. It has to be referenced from
Web.config file

5. Database connection string should be set in the ConnectionStrings section of


Web.config and NOT in the AppSettings

6. Meaningful names should be given to the controls created in View

9.0 Change Log


Changes Made
V1.0.0 Initial baseline created on 20-May-19 by Ramamoorthy Selvam
Vx.y.z <Please refer the configuration control tool / change item status form if the
details of changes are maintained separately. If not, the template given below
needs to be followed>
Section Changed Effective Changes Effected
No. By Date

Release Id : QTAD-BREQ / 1.4.0 / 13-Jul-2016

C3: Protected Project ID : 1000180469 | 1.0 / Ver: 1.0 15 of 15

You might also like