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.
- 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
- 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
- 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
- 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
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/
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
// 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);
}public interface IUnitOfWork : IDisposable
{
IEmployeeRepository Employees { get; }
IDepartmentRepository Departments { get; }
IProjectRepository Projects { get; }
Task<int> SaveChangesAsync();
Task BeginTransactionAsync();
Task CommitTransactionAsync();
Task RollbackTransactionAsync();
}- 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
- Visual Studio 2022 (17.8 or later) or JetBrains Rider
- .NET 9 SDK or later
- Windows 10/11 (version 1903 or later)
-
Clone the repository
git clone https://github.com/yourusername/WpfApp2.git cd WpfApp2 -
Restore NuGet packages
dotnet restore
-
Database Setup (SQLite - No additional setup required)
# Database file will be created automatically at: ./Database/WpfApp2.db -
Run database migrations
dotnet ef database update
-
Build and run
dotnet build dotnet run
<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" /><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" /><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" />- Personal Information: FirstName, LastName, Email, Phone
- Employment Details: EmployeeNumber, Position, HireDate, Salary
- Relationships: DepartmentId, ManagerId
- Audit Fields: CreatedAt, UpdatedAt, CreatedBy, UpdatedBy
- Basic Information: Name, Code, Description
- Financial: Budget tracking
- Management: ManagerId (self-referencing)
- Audit Fields: Complete audit trail
- Project Details: Name, Code, Description
- Timeline: StartDate, EndDate, EstimatedEndDate
- Financial: Budget, ActualCost
- Status Tracking: Status, Priority, ProgressPercentage
- Relationships: DepartmentId, ProjectManagerId
- Assignment Details: Role, HourlyRate, AllocationPercentage
- Timeline: AssignedDate, UnassignedDate
- Status: IsActive flag
- Milestone Information: Name, Description, DueDate
- Completion: CompletedDate, IsCompleted, ProgressPercentage
- Priority: IsCritical flag
- β 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
- π Service layer implementation
- π Business logic validation
- π Transaction management
- π Error handling and logging
- π MVVM ViewModels
- π WPF Views with data binding
- π CRUD operations interface
- π Data validation and error display
- π Reporting and analytics
- π Data export/import
- π Advanced search and filtering
- π Performance optimizations
- 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
- 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
- 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
[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);
}- Test repository operations with real database
- Verify transaction behavior with Unit of Work
- Test constraint violations and error handling
- Validate audit logging functionality
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Microsoft Entity Framework Team for the excellent ORM framework
- SQLite Team for the lightweight database engine
- Open Source Community for invaluable tools and libraries
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Check the
/docsfolder for detailed guides
Made with β€οΈ for Enterprise Development