A desktop-based e-commerce management system built with Windows Forms and Entity Framework Core, implementing a clean layered architecture. The application manages shop operations including product catalog, customer management, order processing, and payment handling with a focus on maintainability and separation of concerns.
- Product Management – Add, edit, delete, search, and soft-delete products
- Category Management – Organize products by categories
- Shopping Cart – Add items to cart, manage cart items, multiple stored carts per customer
- Order Processing – Complete checkout, create orders, track order status (Pending, Processing, Shipped, Delivered, Cancelled)
- Payment Management – Support for multiple payment methods (Credit Card, PayPal)
- Invoice & Payment Tracking – Generate invoices, track payments per order
- Customer Management – Registration, authentication, profile management with profile images
- Product Reviews – Customers can review purchased products with ratings and timestamps
- Inventory Tracking – Stock quantity management with validation
- Data Validation – Input validation for products, payments, and customer data
- Persistent Storage – Entity Framework Core with SQL Server
- Soft Delete Pattern – Products support soft deletion with interceptor implementation
The application follows a 3-tier layered architecture ensuring separation of concerns:
ECommerceManagementSystem/
├── UI/ # Presentation Layer (Windows Forms)
│ ├── Views (Forms & Controls)
│ ├── User Controls
│ └── Program.cs
│
├── Business/ # Business Logic Layer
│ ├── Services/
│ │ ├── ProductService.cs
│ │ ├── CartService.cs
│ │ ├── OrderService.cs
│ │ ├── AccountService.cs
│ │ └── PaymentMethodService.cs
│ ├── Repositories/
│ │ ├── ProductRepository.cs
│ │ ├── CategoryRepository.cs
│ │ ├── OrderRepository.cs
│ │ ├── CustomerRepository.cs
│ │ └── ...
│ └── Interfaces/
│ ├── IRepository.cs
│ ├── IAccountRepository.cs
│ └── IByCustomerRepository.cs
│
└── Data/ # Data Access Layer
├── Context/
│ ├── AppDbContext.cs
│ ├── MiniShopContextFactory.cs
│ ├── Configurations/ # Entity Type Configurations
│ └── Interceptors/ # Soft Delete Interceptor
├── Entities/
│ ├── Product.cs
│ ├── Category.cs
│ ├── Order.cs
│ ├── Customer.cs
│ ├── Account.cs
│ ├── Invoice.cs
│ ├── Payment.cs
│ ├── Cart.cs
│ └── ...
├── DTOs/
└── Migrations/
- Presentation Layer → Windows Forms UI only handles display logic and user interaction
- Business Logic Layer → Services encapsulate business rules and orchestrate operations
- Data Access Layer → Repositories abstract database operations
- UI does not directly access the database – All data operations go through services and repositories
- Entity Type Configurations – Fluent API configurations separate from entity classes
- Dependency Injection – Context passed through constructors
- AppDbContext – Central database context managing all entity sets
- DbSet – Strongly-typed collections for Products, Orders, Customers, Categories, Payments, etc.
- Lazy Loading Proxies – Navigation properties loaded on demand
- Connection String Management – Configured via
ConfigurationManager - Change Tracking – Custom event handlers for tracking and saving changes
- Code-First Approach – Database schema generated from entity models
- 30+ Migrations – Progressive schema evolution including:
- Initial database creation
- Product images support
- Soft delete implementation
- Cart functionality enhancements
- Payment method validation
- Profile images for accounts
- Product descriptions and reviews
- Repository pattern with LINQ for data retrieval
- Complex queries using
.Include()and.ThenInclude()for eager loading - Filtering with
.Where(),.FirstOrDefault(),.OfType<T>() - Aggregations for statistics (order counts, total spent, product reviews)
- One-to-Many: Category → Products, Customer → Orders, Order → OrderItems
- One-to-One: Order → Invoice, Account → LoginCreds
- Many-to-Many: Managed through join entities (OrderItem, CartItem)
- Navigation Properties – Virtual properties with lazy loading enabled
- Foreign Key Constraints – Enforced through EF Core conventions and configurations
- Soft Delete Interceptor – Implements
ISoftDeletableinterface with query filtering - Owned Entity Types –
Address,BirthDate,LoginCredsconfigured as owned types - Table-Per-Hierarchy (TPH) – Account base class with Customer and Admin discriminators
- Value Conversions – Enum to integer mappings for OrderStatus
- Seeding Data – Initial shipping cost records
- Inventory schema – Products table
- dbo schema – Core tables (Orders, Customers, Categories, Invoices, Payments, etc.)
Account (Abstract)
├── Customer (1:M) → Orders
└── Admin
Category (1:M) → Product
Product
├── (M:1) → Category
├── (1:M) → ProductReview
├── (1:M) → OrderItem
└── (1:M) → CartItem
Order
├── (M:1) → Customer
├── (M:1) → PaymentMethod
├── (1:1) → Invoice
├── (M:1) → ShippingCost
└── (1:M) → OrderItem
Invoice (1:M) → Payment
Cart
├── (M:1) → Customer
└── (1:M) → CartItem
PaymentMethod (Abstract)
├── CreditCardPaymentMethod
└── PayPalPaymentMethod
- Primary Keys – Identity columns on all entities
- Foreign Keys – Enforced relationships with referential integrity
- Unique Constraints – Email uniqueness for accounts
- Required Fields – Product name, customer email, order dates
- Data Validation – Credit card validation, email format, price/stock constraints
- Cascade Delete – Configured for CartItems when Cart is deleted
- Soft Delete – Products marked as
IsDeletedrather than physically removed
- C# 10
- .NET 10
- Windows Forms – Desktop UI framework
- Entity Framework Core 10.0.1 – ORM for data persistence
- SQL Server – Relational database
- Microsoft.Extensions.Logging.Console – Logging infrastructure
- System.Configuration.ConfigurationManager – Connection string management
-
Clone the repository
git clone <repository-url> cd ECommerceManagementSystem
-
Update the connection string
- Open
App.config(or configuration file) - Update the
MiniShopDBStringconnection string to point to your SQL Server instance:<connectionStrings> <add name="MiniShopDBString" connectionString="Server=YOUR_SERVER;Database=ECommerceManagementSystem;Integrated Security=true;TrustServerCertificate=true;" providerName="System.Data.SqlClient" /> </connectionStrings>
- Open
-
Apply database migrations
cd Data dotnet ef database update -
Build the solution
dotnet build
-
Run the application
cd UI dotnet run
- Layered Architecture – UI, Business Logic, and Data Access separation
- Separation of Concerns – Each layer has distinct responsibilities
- Repository Pattern – Abstraction over data access operations
- Service Layer Pattern – Business logic encapsulation
- EF Core Data Persistence – Code-first approach with migrations
- Entity Type Configurations – Fluent API for complex mappings
- Soft Delete Pattern – Interceptor-based implementation
- Table-Per-Hierarchy Inheritance – Account hierarchy (Customer/Admin)
- Owned Entity Types – Value objects for Address, BirthDate, LoginCreds
- Navigation Properties – Lazy loading for related entities
- Data Validation – Business rule enforcement in services
- Exception Handling – Try-catch blocks with user-friendly error messages
- LINQ Queries – Type-safe database queries
- Dependency Injection (Constructor) – Context passed through constructors
- Desktop-based only – No web or mobile interface
- No authentication/authorization system – Basic login credentials without JWT or role-based security
- Limited reporting – Basic order and sales statistics only
- Single-tenant – Not designed for multi-tenant scenarios
- No real-time updates – Manual refresh required for data changes
- Basic search functionality – No advanced filtering or full-text search
- No email notifications – Order confirmations not sent via email
- Limited payment integration – Payment methods stored locally, no actual payment gateway integration
- Implement role-based access control (RBAC)
- Add comprehensive reporting and analytics dashboard
- Integrate real payment gateways (Stripe, PayPal API)
- Implement email notification system
- Add advanced search with filters and pagination
- Create admin panel for system configuration
- Add unit and integration tests
- Implement caching for frequently accessed data
This project is for educational purposes demonstrating layered architecture and Entity Framework Core usage.