Tuesday, November 29, 2016

Example: N-Tier Application

Problem Statement: It has two parts: 
  • Create a two page Bank Application where first page has two button one to add data into the database second to take you to the second page which shows the account details.
  • Each account holder has two accounts and each account has minimum 5 transactions.
 Solution Approach: We will be needing following items:
  • Two ASP.NET web pages.
  • Entities: AccountHolder, Account, Transaction. 
  • A way to do CRUD operation for items in Database.
Lets create n-tier application and divide above items into the different layers based on the previous post:
  • Entities Layer
    • Define POCOs 
      • AccountHolder.cs
      • Account.cs
      • Transaction.cs 
    • These classes represent Database tables as well as model for Presentation layer.
  • Data Access Layer
    • Use Entity Framework and define context to access database. (we are using Entity Framework code first approach) 
  • Business Components Layer
    • Contains core operations for the data access layer methods, using following contracts (interfaces) and classes. The interfaces defines the different core operations as methods and classes has the implementation of those methods. 
      • IBaseService
      • BaseService
      • IAccountHoldersService.cs
      • IAccountsService.cs
      • ITrsancationsService.cs
      • AccountHoldersService.cs
      • AccountsService.cs
      • TrasactionsService.cs
  • Services Layer 
    • As of now for this application, the Services layer is not required since we are not sharing any data with other systems. In case the data needs to be shared  with other systems, we will create either a Web Service or WCF service or ASP.NET Web API. In case we are using ASP.NET Web APIs to create this layer, it will have following controller classes:
      • AccountHoldersController.cs
      • AccountsController,cs
      • TransactiosController.cs
  • Presentation Layer
    • Use ASP.NET WebForms
    • The MainPage.aspx and TransactionDetails.aspx






You can download the Visual Studio solution for the above Bank Application from here: Bank Application using N-Tier Architecture.

No comments:

Post a Comment