Skip to content

3mrotaha/E-Commerce-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E-Commerce Management System – WinForms + EF Core

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.


Core Features

  • 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

Architecture

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/

Key Architectural Principles:

  • 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

Entity Framework Core Usage

DbContext Implementation

  • 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

Migrations

  • 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

LINQ Queries

  • 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)

Relationship Handling

  • 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

Advanced Features

  • Soft Delete Interceptor – Implements ISoftDeletable interface with query filtering
  • Owned Entity TypesAddress, BirthDate, LoginCreds configured 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

Database Design

Database Provider: SQL Server

Schema Organization

  • Inventory schema – Products table
  • dbo schema – Core tables (Orders, Customers, Categories, Invoices, Payments, etc.)

Key Entities & Relationships

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

Key Constraints

  • 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 IsDeleted rather than physically removed

Technologies Used

  • 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

How to Run

  1. Clone the repository

    git clone <repository-url>
    cd ECommerceManagementSystem
  2. Update the connection string

    • Open App.config (or configuration file)
    • Update the MiniShopDBString connection 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>
  3. Apply database migrations

    cd Data
    dotnet ef database update
  4. Build the solution

    dotnet build
  5. Run the application

    cd UI
    dotnet run

Key Concepts Applied

  • 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

Limitations

  • 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

Future Enhancements

  • 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

License

This project is for educational purposes demonstrating layered architecture and Entity Framework Core usage.

About

Layered e-commerce management system built with C#, WinForms, and EF Core featuring repository pattern, soft delete interceptor, TPH inheritance, and complex relational modeling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages