Skip to content

OurDotNetOrganization/WPF-App

Repository files navigation

πŸš€ WPF Enterprise Application with Advanced Data Access Layer

πŸ“‹ Project Overview

WPF Enterprise Application is a sophisticated Windows Presentation Foundation (WPF) application built with .NET 9, showcasing modern development practices, advanced UI/UX patterns, and enterprise-grade architecture. This project demonstrates a comprehensive business management system with a robust Entity Framework Core-based data access layer, implementing Repository and Unit of Work patterns for optimal data management.

✨ Key Features

πŸ—οΈ Architecture & Patterns

  • MVVM (Model-View-ViewModel) pattern with proper separation of concerns
  • Repository Pattern with generic and specialized repositories
  • Unit of Work Pattern for transaction management
  • Entity Framework Core with Code-First approach
  • Dependency Injection using Microsoft.Extensions.DependencyInjection
  • Command Pattern with ICommand implementations
  • Observer Pattern with INotifyPropertyChanged
  • Factory Pattern for object creation

πŸ—„οΈ Advanced Data Access Layer

  • Entity Framework Core 8.0 with SQLite database
  • Generic Repository Pattern with comprehensive CRUD operations
  • Unit of Work Pattern for transaction coordination
  • Automatic Audit Logging with change tracking
  • Optimized Database Queries with proper indexing
  • Bulk Operations for performance optimization
  • Database Migrations with seed data
  • Connection Resilience and error handling

πŸ“Š Business Domain Models

  • Employee Management with hierarchical relationships
  • Department Management with budget tracking
  • Project Management with status and priority tracking
  • Project Assignments with role-based allocations
  • Project Milestones with progress tracking
  • Comprehensive Audit Logging for compliance

🎨 Modern UI/UX Features

  • Material Design inspired interface with custom styling
  • Dark/Light Theme switching with smooth transitions
  • Responsive Layout that adapts to different screen sizes
  • Custom Controls and UserControls for reusability
  • Smooth Animations and micro-interactions
  • Accessibility Support with proper ARIA labels

πŸ›οΈ Project Structure

WpfApp2/
β”œβ”€β”€ πŸ“ Models/                      # Domain Models & Entities
β”‚   β”œβ”€β”€ Employee.cs                 # Employee entity with relationships
β”‚   β”œβ”€β”€ Department.cs               # Department entity with budget tracking
β”‚   β”œβ”€β”€ Project.cs                  # Project entity with status/priority
β”‚   β”œβ”€β”€ ProjectAssignment.cs        # Many-to-many relationship entity
β”‚   β”œβ”€β”€ ProjectMilestone.cs         # Project milestone tracking
β”‚   └── AuditLog.cs                 # Comprehensive audit logging
β”œβ”€β”€ πŸ“ Data/                        # Entity Framework Core Data Layer
β”‚   β”œβ”€β”€ ApplicationDbContext.cs     # Main EF DbContext with configurations
β”‚   β”œβ”€β”€ Repositories/               # Repository pattern implementation
β”‚   β”‚   β”œβ”€β”€ Interfaces/
β”‚   β”‚   β”‚   β”œβ”€β”€ IRepository.cs      # Generic repository interface
β”‚   β”‚   β”‚   β”œβ”€β”€ IUnitOfWork.cs      # Unit of work interface
β”‚   β”‚   β”‚   β”œβ”€β”€ IEmployeeRepository.cs
β”‚   β”‚   β”‚   β”œβ”€β”€ IDepartmentRepository.cs
β”‚   β”‚   β”‚   └── IProjectRepository.cs
β”‚   β”‚   β”œβ”€β”€ Repository.cs           # Generic repository implementation
β”‚   β”‚   β”œβ”€β”€ UnitOfWork.cs          # Unit of work implementation
β”‚   β”‚   β”œβ”€β”€ EmployeeRepository.cs   # Specialized employee operations
β”‚   β”‚   β”œβ”€β”€ DepartmentRepository.cs # Specialized department operations
β”‚   β”‚   └── ProjectRepository.cs    # Specialized project operations
β”‚   └── Migrations/                 # EF Core migrations
β”œβ”€β”€ πŸ“ Services/                    # Business Logic Services
β”‚   β”œβ”€β”€ Interfaces/
β”‚   β”‚   β”œβ”€β”€ IEmployeeService.cs
β”‚   β”‚   β”œβ”€β”€ IDepartmentService.cs
β”‚   β”‚   β”œβ”€β”€ IProjectService.cs
β”‚   β”‚   └── IAuditService.cs
β”‚   β”œβ”€β”€ EmployeeService.cs
β”‚   β”œβ”€β”€ DepartmentService.cs
β”‚   β”œβ”€β”€ ProjectService.cs
β”‚   └── AuditService.cs
β”œβ”€β”€ πŸ“ ViewModels/                  # MVVM ViewModels
β”‚   β”œβ”€β”€ Base/
β”‚   β”‚   β”œβ”€β”€ BaseViewModel.cs
β”‚   β”‚   └── RelayCommand.cs
β”‚   β”œβ”€β”€ MainViewModel.cs
β”‚   β”œβ”€β”€ EmployeeViewModel.cs
β”‚   β”œβ”€β”€ DepartmentViewModel.cs
β”‚   └── ProjectViewModel.cs
β”œβ”€β”€ πŸ“ Views/                       # WPF Views and Windows
β”‚   β”œβ”€β”€ MainWindow.xaml
β”‚   β”œβ”€β”€ EmployeeManagementView.xaml
β”‚   β”œβ”€β”€ DepartmentView.xaml
β”‚   └── ProjectManagementView.xaml
β”œβ”€β”€ πŸ“ Configuration/               # Application Configuration
β”‚   β”œβ”€β”€ appsettings.json           # Database connection strings
β”‚   β”œβ”€β”€ appsettings.Development.json
β”‚   └── appsettings.Production.json
└── πŸ“ Tests/                      # Unit and Integration Tests
    β”œβ”€β”€ RepositoryTests/
    β”œβ”€β”€ ServiceTests/
    └── IntegrationTests/

πŸ—„οΈ Data Access Layer Architecture

Entity Relationships

Employee (1) ←→ (N) Department
Employee (1) ←→ (N) Employee (Manager-DirectReports)
Project (1) ←→ (N) Department
Project (1) ←→ (N) ProjectAssignment ←→ (N) Employee
Project (1) ←→ (N) ProjectMilestone
Employee (1) ←→ (N) AuditLog

Repository Pattern Features

// Generic Repository Interface
public interface IRepository<T> where T : class
{
    // Basic CRUD Operations
    Task<T?> GetByIdAsync(int id);
    Task<IEnumerable<T>> GetAllAsync();
    Task<T> AddAsync(T entity);
    Task UpdateAsync(T entity);
    Task DeleteAsync(int id);
    
    // Advanced Querying
    Task<IEnumerable<T>> FindAsync(Expression<Func<T, bool>> predicate);
    Task<T?> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate);
    Task<bool> ExistsAsync(Expression<Func<T, bool>> predicate);
    
    // Pagination & Sorting
    Task<PagedResult<T>> GetPagedAsync(int pageNumber, int pageSize);
    Task<IEnumerable<T>> GetAllSortedAsync<TKey>(Expression<Func<T, TKey>> keySelector);
    
    // Bulk Operations
    Task AddRangeAsync(IEnumerable<T> entities);
    Task UpdateRangeAsync(IEnumerable<T> entities);
    Task DeleteRangeAsync(IEnumerable<T> entities);
    
    // Counting
    Task<int> CountAsync();
    Task<int> CountAsync(Expression<Func<T, bool>> predicate);
}

Unit of Work Pattern

public interface IUnitOfWork : IDisposable
{
    IEmployeeRepository Employees { get; }
    IDepartmentRepository Departments { get; }
    IProjectRepository Projects { get; }
    
    Task<int> SaveChangesAsync();
    Task BeginTransactionAsync();
    Task CommitTransactionAsync();
    Task RollbackTransactionAsync();
}

Entity Configurations

  • Complete Property Mapping with proper data types
  • Optimized Indexing for better query performance
  • Foreign Key Relationships with appropriate cascade behaviors
  • Default Values and constraints
  • Audit Field Automation with timestamps

πŸš€ Getting Started

Prerequisites

  • Visual Studio 2022 (17.8 or later) or JetBrains Rider
  • .NET 9 SDK or later
  • Windows 10/11 (version 1903 or later)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/WpfApp2.git
    cd WpfApp2
  2. Restore NuGet packages

    dotnet restore
  3. Database Setup (SQLite - No additional setup required)

    # Database file will be created automatically at: ./Database/WpfApp2.db
  4. Run database migrations

    dotnet ef database update
  5. Build and run

    dotnet build
    dotnet run

πŸ“¦ NuGet Packages

Core Dependencies

<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />

Entity Framework Core

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0" />

Testing

<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0" />

πŸ—ƒοΈ Database Schema

Employee Table

  • Personal Information: FirstName, LastName, Email, Phone
  • Employment Details: EmployeeNumber, Position, HireDate, Salary
  • Relationships: DepartmentId, ManagerId
  • Audit Fields: CreatedAt, UpdatedAt, CreatedBy, UpdatedBy

Department Table

  • Basic Information: Name, Code, Description
  • Financial: Budget tracking
  • Management: ManagerId (self-referencing)
  • Audit Fields: Complete audit trail

Project Table

  • Project Details: Name, Code, Description
  • Timeline: StartDate, EndDate, EstimatedEndDate
  • Financial: Budget, ActualCost
  • Status Tracking: Status, Priority, ProgressPercentage
  • Relationships: DepartmentId, ProjectManagerId

Project Assignment Table

  • Assignment Details: Role, HourlyRate, AllocationPercentage
  • Timeline: AssignedDate, UnassignedDate
  • Status: IsActive flag

Project Milestone Table

  • Milestone Information: Name, Description, DueDate
  • Completion: CompletedDate, IsCompleted, ProgressPercentage
  • Priority: IsCritical flag

🎯 Development Roadmap

Phase 1: Data Foundation βœ… (Completed)

  • βœ… Entity Framework Core setup with SQLite
  • βœ… Complete domain models with relationships
  • βœ… Repository pattern implementation
  • βœ… Unit of Work pattern
  • βœ… Comprehensive entity configurations
  • βœ… Database migrations and seed data
  • βœ… Audit logging system

Phase 2: Business Services πŸ”„ (In Progress)

  • πŸ”„ Service layer implementation
  • πŸ”„ Business logic validation
  • πŸ”„ Transaction management
  • πŸ”„ Error handling and logging

Phase 3: UI Implementation πŸ“‹ (Planned)

  • πŸ“‹ MVVM ViewModels
  • πŸ“‹ WPF Views with data binding
  • πŸ“‹ CRUD operations interface
  • πŸ“‹ Data validation and error display

Phase 4: Advanced Features πŸ“‹ (Future)

  • πŸ“‹ Reporting and analytics
  • πŸ“‹ Data export/import
  • πŸ“‹ Advanced search and filtering
  • πŸ“‹ Performance optimizations

πŸ› οΈ Development Guidelines

Database Best Practices

  • Use migrations for all schema changes
  • Implement proper indexing for query optimization
  • Follow naming conventions for tables and columns
  • Use appropriate data types and constraints
  • Implement audit trails for sensitive data

Repository Pattern Guidelines

  • Keep repositories focused on data access only
  • Use async/await for all database operations
  • Implement proper error handling
  • Use generic repositories for common operations
  • Create specialized repositories for complex queries

Performance Considerations

  • Use Include() for eager loading related data
  • Implement pagination for large datasets
  • Use AsNoTracking() for read-only operations
  • Optimize query execution with proper indexing
  • Monitor database performance regularly

πŸ§ͺ Testing Strategy

Repository Testing

[Fact]
public async Task GetByIdAsync_WithValidId_ReturnsEmployee()
{
    // Arrange
    using var context = GetInMemoryContext();
    var repository = new EmployeeRepository(context, logger);
    
    // Act
    var employee = await repository.GetByIdAsync(1);
    
    // Assert
    Assert.NotNull(employee);
    Assert.Equal("John", employee.FirstName);
}

Integration Testing

  • Test repository operations with real database
  • Verify transaction behavior with Unit of Work
  • Test constraint violations and error handling
  • Validate audit logging functionality

πŸ“š Learning Resources

Entity Framework Core

Design Patterns

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Microsoft Entity Framework Team for the excellent ORM framework
  • SQLite Team for the lightweight database engine
  • Open Source Community for invaluable tools and libraries

πŸ“ž Support


Made with ❀️ for Enterprise Development

About

A sophisticated Windows Presentation Foundation (WPF) application built with .NET 9, showcasing modern development practices, advanced UI/UX patterns, and enterprise-grade architecture. This project demonstrates a comprehensive business management system with a robust Entity Framework Core-based data access layer.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages