Introduction

Timesheets are essential for tracking employee work hours, project allocation, and payroll. Yet, many organizations still rely on manual spreadsheets, which are error-prone and inefficient. In this article, we’ll build a Web-Based Timesheet Management System using ASP.NET Core MVC and SQL Server.

We’ll start with the basics — employee timesheet entry and project allocation — and then move into advanced features like approval workflows, authentication, reporting, and deployment. By the end, you’ll have a portfolio-ready application that demonstrates enterprise-grade skills in ASP.NET Core.

Step 1: Project Setup

Clone the Repository

git clone https://github.com/brajeshkr18/WebTimeSheetManagement.git
cd WebTimeSheetManagement

Configure SQL Server in appsettings.json

"ConnectionStrings": {
  "DefaultConnection": "Server=.;Database=TimeSheetDB;Trusted_Connection=True;"
}

Run EF Core Migrations

dotnet ef database update

Launch the Application

dotnet run

Step 2: Architecture Overview

The project follows a layered MVC structure:

LayerPurposeExample
ControllersHandle requestsTimesheetController, ProjectController
ModelsDefine entitiesTimesheet, Employee, Project
ViewsUI with Razor PagesTimesheet/Index.cshtml
DataEF Core DbContextApplicationDbContext
ServicesBusiness logicTimesheetService

Step 3: Timesheet Entry

Employees can log daily/weekly hours against projects.

public class Timesheet
{
    public int Id { get; set; }
    public int EmployeeId { get; set; }
    public int ProjectId { get; set; }
    public DateTime Date { get; set; }
    public decimal HoursWorked { get; set; }
}

Step 4: Project Allocation

Managers assign employees to projects.

Step 5: Approval Workflow

Managers approve or reject submitted timesheets.

public class TimesheetApproval
{
    public int Id { get; set; }
    public int TimesheetId { get; set; }
    public string Status { get; set; } // Pending, Approved, Rejected
    public DateTime ActionDate { get; set; }
}

🔐 Step 6: Authentication & Roles

Secure the system with ASP.NET Core Identity.

Roles

[Authorize(Roles = "Manager")]
public IActionResult ApproveTimesheet(int id)
{
    ...
}

This ensures only authorized users can perform sensitive actions.

📊 Step 7: Reporting

Generate reports for payroll and productivity.

Reports

Example LINQ Query

var weeklyReport = _context.Timesheets
    .Where(t => t.Date >= startDate && t.Date <= endDate)
    .GroupBy(t => t.EmployeeId)
    .Select(g => new
    {
        EmployeeId = g.Key,
        TotalHours = g.Sum(t => t.HoursWorked)
    })
    .ToList();

Export Options

🌐 Step 8: Deployment

dotnet ef database update

🎯 Conclusion

With all steps complete, you now have a full-featured Web-Based Timesheet Management System: