Download - 3-TIER ARCHITECTURE IN ASP.NET MVC

Transcript
Page 1: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Live Project - Web Appon Asp.Net MVC

- Mohd Manzoor Ahmed (MCTS, MCPD & MCT)

www.manzoorthetrainer.com

Page 2: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Project Plan

● Understanding Requirements and Database Design.● Creating Solution and Adding projects to It.● Creating The business Objects.● Creating Data Access Layer in EF.● Creating Business Logic Layer in C#.Net.● Creating Presentation Logic Layer in MVC5.● Designing Models, Controllers and Views.● Business Rules Validations.● Securing Your App.● Implementing Transactions.● Ajaxifying Your App.● Conclusion And Feedback

Page 3: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Finalized Requirements

Link hub is a web portal where a user can submit their portal URL under a specific category to be shared on link hub. Admin can approve or reject the URL submitted by the user and in each case an email is sent out to the user. Once the link is approve it will be available on the link hub portal under a specific category.

Page 4: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Defining the Roles & Responsibilities

Roles:

• Usero Can Browse URLso Can Registero Can Submit A URL

• Admino Can CRUD Category o Can View All Userso Can ApproveOrReject URL

Page 5: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Identifying the Objects

• User

• Category

• Url

Page 6: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating The Relationships

• Category : Url 1--------------------> n

n--------------------> 1 (X)

n--------------------> n (X)

o (1:M)

Page 7: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating The Relationships

• User : Url 1--------------------> n

n--------------------> 1 (X)

n--------------------> n (X)

o (1:M)

Page 8: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating The Relationships

• Objectso Usero Categoryo Url

• Relationships

o Category : Url (1:M)

o User : Url (1:M)

Page 9: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

3 Key Rules For Database Design

1. One table for each object

2. For 1:M relationship. 1 will become master and M will become child i.e., primary key of 1 will act as a foreign key for M.

Eg:Department : Employees is 1 : M

Department Table

Did

DName

Description

Employee Table

Eid

EName

ESalary

Did

Page 10: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

3 Key Rules For Database Design

3. M:M relationship. Both the objects will become master and there will be one more new table called as transaction table or child table with primary keys of masters as foreign Keys in it.

Eg:Student : Course is M : M

Student Table

Sid

SName

SAddress

Course Table

Cid

CName

Description

Student_Course Table

SCId

Sid

Cid

Page 11: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Designing Database

tbl_Category

CategoryId

tbl_Url

UrlId

UId

CategoryId

tbl_User

UId

Role

Page 12: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Implementing DatabaseLets go and Implement

Page 13: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Inserting Dummy RecordsLets go and Insert dummy and meaningful records

Page 14: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Design Project Arch.

DALAdo.Net

EF

Result c

BLLC#.Net

c=a+b

UIAsp.Net

MVC

a=10;b=20;

show c

DatabaseMS SQL

Business Objects (BO)

Page 15: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Design Project Arch.

● UI● BLL● DAL● BOL

Page 16: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating Solution and Adding projects to ItLets go and implement it

Page 17: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating The business ObjectsBasically a business object layer contains classes equivalent to the tables i.e.,

one class for each table.Eg:If I have a department table

tbl_Department (Relation)

Did

DName

Description

\\Objectclass tbl_Department {Public int Did {get;set;}Public string DName {get;set;}Public string Description {get;set;}}

i.e., O/R M

Lets go and implement it

Page 18: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating The business Objects - Relationship(1:M)

\\Objectclass tbl_Deptartment{public int Did {get;set;}public string DName {get;set;}public string Description {get;set;}public virtual List<tbl_Employee> tbl_Employees {get;set;}}

tbl_Department

Did

DName

Description

tbl_Employee

Eid

EName

ESalary

Did

\\Objectclass tbl_Employee{public int Eid{get;set;}public string EName {get;set;}public double Esalary {get;set;}public int Did{get;set;}public virtual tbl_Department {get;set;}}

Page 19: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating The business Objects - Relationship(M:M)

tbl_Student

Sid

SName

SAddress

tbl_Course

Cid

CName

Description

tbl_Student_Course

SCId

Sid

Cid

Page 20: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating The business Objects - Relationship(M:M)

\\Objectclass tbl_Student{public int Sid{get;set;}public string SName {get;set;}public string Address {get;set;}public virtual List<tbl_Student_Course> tbl_Student_Courses {get;set;}}

\\Objectclass tbl_Course{public int Cid{get;set;}public string CName {get;set;}public string CDescription {get;set;}public virtual List<tbl_Student_Course> tbl_Student_Courses {get;set;}}

\\Objectclass tbl_Student_Course{public int SCid{get;set;}public int Sid {get;set;}public int Cid {get;set;}public virtual tbl_Student {get;set;}public virtual tbl_Course {get;set;}}

Page 21: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating Of UI/PL

DALAdo.N

etEF

Result c

BLLC#.Net

c=a+b

UIAsp.Net

a=10;b=20;

show c

DatabaseMS SQL

Business Objects (BO)

DatabaseMS SQL

Business Objects (BO)

UIAsp.Net

MVC

a=10;b=20;

show c

Page 22: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Roles & Responsibilities

Roles:

• Usero Can Browse URLso Can Registero Can Submit A URL

• Admino Can CRUD Category o Can View All Userso Can ApproveOrReject URL

Page 23: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Home

Page 24: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Category

Page 25: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

ListCategories

Page 26: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Register

Page 27: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

SubmitURL

Page 28: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

ApproveURLs

Page 29: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

BrowseURLs

Page 30: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

ListUsers

Page 31: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Login

Page 32: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

UI - Modules

• Usero SubmitURL

• Admino Categoryo ListCatergorieso ListUserso ApproveURLs

• Commono Homeo BrowseURLs

• Securityo Logino Register

Page 33: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

SubmitURL

Page 34: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

User Controllers Design

Controller Action

URL Index [Display Form - HttpGet]

Create [Submit Form - HttpPost]

Page 35: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Admin Controllers Design Controller Action

Category Index[Display Form - HttpGet]

Create [Submit Form - HttpPost]

ListCategory Index [Display List - HttpGet]

ListUser Index [Display List - HttpGet]

ApproveURLs Index [Display List - HttpGet]

Approve [Submit Form- HttpPost]

Page 36: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Category

Page 37: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

CategoriesList

Page 38: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

List Users

Page 39: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Approve URLs

Page 40: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Common Controllers Design

Controller Action

Home Index [Display Calender - HttpGet]

BrowseURLs Index [Display List Form - HttpGet]

Page 41: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Home

Page 42: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Browse Urls

Page 43: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Security Controllers Design

Controller Action

Login Index[Display Form- HttpGet]

SignIn[Submit Form - HttpPost]

Register Index[Display Form - HttpGet]

Create[Submit Form- HttpPost]

Page 44: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Login

Page 45: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Registration

Page 46: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating Data Access LayerLets go and implement it

Page 47: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating Business Logic LayerLets go and implement it

Page 48: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Creating Of UI/PL

DALAdo.Net

Result c

BLLC#.Net

c=a+b

UIAsp.Net

a=10;b=20;

show c

DatabaseMS SQL

Business Objects (BO)

DatabaseMS SQL

Business Objects (BO)

UIAsp.Net

a=10;b=20;

show c

BLLC#.Net

c=a+b

DALAdo.Net

Result c

Page 49: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Form ValidationsLets go and implement it

Page 50: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Business Rule ValidationsLets go and implement it

Page 51: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

AuthenticationLets go and implement it

Page 52: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

AuthorizationLets go and implement it

Page 53: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Applying Bootstrap Theme

Lets go and implement it

Page 54: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Advanced Operations

• Binding multiple models to a single View• Implementing transactions• Ajaxifying MVC App• External Logins [Like Facebook Login]

Page 55: 3-TIER ARCHITECTURE IN ASP.NET MVC

www.ManzoorTheTrainer.com | Enroll here [MVC 3-Tier (50% Off)] :http://goo.gl/iMulis

Thanks