create an ASP.NET Core–based “task raised” system, and you want it explained from basic to advanced concepts, including real-time examples.
Let’s go step-by-step — from concept ➜ basic implementation ➜ advanced enhancements.
Project Concept: “Task Raised System” (Task Management App)
A Task Raised System allows users to:
Raise (create) new tasks
Assign tasks to team members
Track status (Pending, In Progress, Completed)
Send notifications or background updates
Basic Level: Core Concepts
1. Create a new ASP.NET Core Project
dotnet new webapp -n TaskManagerApp
cd TaskManagerApp
2. Define a Task Model
public class TaskItem
{
public int Id { get; set; }
public string Title { get; set; } = "";
public string Description { get; set; } = "";
public string AssignedTo { get; set; } = "";
public string Status { get; set; } = "Pending";
public DateTime CreatedDate { get; set; } = DateTime.Now;
}
3. Create an EF Core DbContext
using Microsoft.EntityFrameworkCore;
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
public DbSet<TaskItem> Tasks { get; set; }
}
4. Configure Database in Program.cs
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
appsettings.json
"ConnectionStrings": {
"DefaultConnection": "Server=.;Database=TaskManagerDB;Trusted_Connection=True;"
}
Intermediate Level: CRUD Operations (Task Raised Flow)
1. Controller: TaskController.cs
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
public class TaskController : Controller
{
private readonly AppDbContext _context;
public TaskController(AppDbContext context)
{
_context = context;
}
public async Task<IActionResult> Index()
{
var tasks = await _context.Tasks.ToListAsync();
return View(tasks);
}
[HttpGet]
public IActionResult Create() => View();
[HttpPost]
public async Task<IActionResult> Create(TaskItem task)
{
_context.Tasks.Add(task);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
[HttpGet]
public async Task<IActionResult> Edit(int id)
{
var task = await _context.Tasks.FindAsync(id);
return View(task);
}
[HttpPost]
public async Task<IActionResult> Edit(TaskItem task)
{
_context.Update(task);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
[HttpGet]
public async Task<IActionResult> Delete(int id)
{
var task = await _context.Tasks.FindAsync(id);
_context.Tasks.Remove(task);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
}
2. Views (Razor Pages)
Create.cshtml
<form asp-action="Create" method="post">
<label>Title:</label>
<input asp-for="Title" />
<label>Description:</label>
<textarea asp-for="Description"></textarea>
<label>Assigned To:</label>
<input asp-for="AssignedTo" />
<button type="submit">Raise Task</button>
</form>
Index.cshtml
@model IEnumerable<TaskItem>
<h2>Task Raised Dashboard</h2>
<a asp-action="Create">Raise New Task</a>
<table>
<tr><th>Title</th><th>Assigned To</th><th>Status</th><th>Actions</th></tr>
@foreach(var t in Model){
<tr>
<td>@t.Title</td>
<td>@t.AssignedTo</td>
<td>@t.Status</td>
<td>
<a asp-action="Edit" asp-route-id="@t.Id">Edit</a> |
<a asp-action="Delete" asp-route-id="@t.Id">Delete</a>
</td>
</tr>}
</table>
Advanced Level: Real-Time and Enterprise Features
1. Use SignalR for Real-Time Task Notifications
When a new task is raised, notify all users instantly.
Install
dotnet add package Microsoft.AspNetCore.SignalR
Create Hub
using Microsoft.AspNetCore.SignalR;
public class TaskHub : Hub
{
public async Task NotifyTaskRaised(string title)
{
await Clients.All.SendAsync("ReceiveTaskNotification", title);
}
}
Integrate in Program.cs
app.MapHub<TaskHub>("/taskHub");
Frontend (in _Layout.cshtml)
<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/7.0.0/signalr.min.js"></script>
<script>
const connection = new signalR.HubConnectionBuilder().withUrl("/taskHub").build();
connection.on("ReceiveTaskNotification", title => {
alert("New task raised: " + title);
});
connection.start();
</script>
When saving task
await _hubContext.Clients.All.SendAsync("ReceiveTaskNotification", task.Title);
2. Background Task Processing (e.g., email or reminder)
Use IHostedService or Hangfire to send reminders automatically for pending tasks.
3. Role-Based Access Control
Add Identity framework for Admin/Employee roles:
4. API Layer (for Mobile Integration)
Create /api/task controller using [ApiController] for integration with a React or Flutter mobile app.
Real-Time Example Summary
| Feature | Description | Example |
|---|
| Raise Task | User submits task form | “Fix payment API” assigned to Ramesh |
| View Dashboard | See all raised tasks | Filter by Pending/Completed |
| Edit Task | Update progress | Change status from Pending → Completed |
| Real-Time Update | Notify everyone when a task is raised | SignalR popup alert |
| Background Task | Auto-reminder email for due date | Hangfire job |
| Role Access | Admin vs User | Admin can delete, user cannot |