Uploaded by amna softwaredeveloper

Assignment1

advertisement
N-Tier Architecture with C# Console Application and
Dapper
Assignment
This assignment introduces you to N-Tier architecture using a C# console application with
Dapper for database interaction.
Case Study: Order Processing System
Develop a simple order processing system with functionalities for adding, updating, deleting,
and searching for orders. The system will utilize a 3-tier architecture consisting of:
•
•
•
Presentation Tier (Console Application): Handles user interaction and displays
information.
Business Logic Layer (Class Library): Implements core functionalities of the
system, interacts with the data access layer, and applies complex business logic.
Data Access Layer (Class Library): Uses Dapper to interact with the database for
CRUD (Create, Read, Update, Delete) operations.
Technologies:
•
•
•
C#
.NET
Dapper
Tasks:
1. Database Setup:
o Create a database with tables for:
▪ Orders (id, customerID, orderDate, totalAmount)
▪ Customers (id, name, address, phone)
▪ OrderItems (id, orderID, productID, quantity, price)
▪ Products (id, name, price, quantity)
o Include scripts to populate the tables with sample data (optional).
2. Data Access Layer (DAL):
o Create a class library project named OrderProcessingDAL.
o Use Dapper to establish a connection to the database.
o Define methods for CRUD operations on:
▪ Orders (including retrieving order details with associated items)
▪ Customers
▪ Products
▪ OrderItems
3. Business Logic Layer (BLL):
o Create a class library project named OrderProcessingBLL.
o This layer interacts with the DAL and implements complex business logic:
▪ Order creation:
▪ Validates customer information (existing customer)
▪ Validates product availability and quantity (sufficient stock)
▪
Calculates total order amount based on product prices and
quantities
▪ Order update:
▪ Validates order existence
▪ Allows updating order items (quantity changes) with stock
validation
▪ Recalculates total order amount
▪ Order deletion:
▪ Validates order existence
▪ Reverts product quantities for deleted order items
▪ Order search:
▪ Allows searching by order ID, customer name, or date range
o Define methods to expose these functionalities.
4. Presentation Tier (Console Application):
o Create a console application project named OrderProcessing.
o Develop a user-friendly menu for:
▪ Listing all orders (with customer and total amount)
▪ Adding a new order (customer selection, product selection with
quantities)
▪ Updating an existing order (modify order items)
▪ Deleting an order
▪ Searching for orders (by ID, customer name, or date range)
o Use the BLL methods to perform operations on the order data.
o Implement proper error handling and user input validation for order creation
and updates.
5. Unit Testing:
o Create a unit test project named OrderProcessingTests (can be xUnit or
NUnit).
o Write unit tests for the following functionalities in the BLL:
▪ Order creation with invalid customer or insufficient stock
▪ Order update with non-existent order or invalid quantity changes
▪ Order deletion with non-existent order
▪ Searching for orders with empty criteria
Deliverables:
•
•
•
•
A well-documented solution with clear separation of concerns between tiers.
Code comments explaining the functionality of each class and method.
A populated database with sample data for customers, products, and orders.
Unit tests demonstrating functionality and error handling.
Grading Rubric:
•
•
•
Tips:
Functionality (60%): Completeness of features, adherence to N-tier architecture with
complex business logic implementation.
Code Quality (20%): Code readability, proper documentation, comments, error
handling.
Unit Testing (20%): Comprehensiveness of test cases, coverage of functionalities.
•
•
•
Use dependency injection to loosely couple the layers.
Implement transactions in the BLL to ensure data integrity (optional challenge).
Consider using design patterns (optional challenge).
Download