Skip to content

Commit 78d11e1

Browse files
Initial Commit
1 parent f1423e6 commit 78d11e1

File tree

96 files changed

+62553
-454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+62553
-454
lines changed

.DS_Store

0 Bytes
Binary file not shown.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Chris Vanderplank - Intrepid Developer
3+
Copyright (c) 2025 Chris Vanderplank - Intrepid Developer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
# ToDo App Series
22

3-
A short YouTube series on getting started with C# coding using a Blazor.
3+
This repository is a tutorial project for my blogging site. It accompanies a short YouTube series on getting started with C# coding using Blazor.
4+
5+
## Prerequisites
6+
7+
- [.NET 9 SDK (latest)](https://dotnet.microsoft.com/download/dotnet/9.0)
8+
- [Docker](https://www.docker.com/get-started)
9+
10+
## Running the Project
11+
12+
1. Ensure you have the latest .NET 9 SDK and Docker installed.
13+
2. Open the solution (`.sln`) file in your preferred IDE (such as Visual Studio or VS Code).
14+
3. Locate the `AppHost` aspire project within the solution.
15+
4. Run the `AppHost` project to start up the application and its dependencies.
16+
17+
---
18+
Happy coding!

ToDo/.idea/.idea.ToDo/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDo/.idea/.idea.ToDo/.idea/AndroidProjectSystem.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDo/.idea/.idea.ToDo/.idea/dataSources.xml

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDo/.idea/.idea.ToDo/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDo/.idea/.idea.ToDo/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDo/.idea/.idea.ToDo/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ToDo/ToDo.Api/Endpoints.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Dapper;
2+
using Microsoft.Data.SqlClient;
3+
using ToDo.Api.Entities;
4+
5+
namespace ToDo.Api;
6+
7+
public static class Endpoints
8+
{
9+
public static void MapToDoEndpoints(this WebApplication app)
10+
{
11+
app.MapGet("/todo", async (SqlConnection conn) =>
12+
{
13+
var items = await conn.QueryAsync<TodoItem>("SELECT * FROM TodoItems");
14+
return Results.Ok(items);
15+
});
16+
17+
app.MapPost("/todo", async (SqlConnection conn, TodoItem item) =>
18+
{
19+
var id = await conn.ExecuteScalarAsync<int>(
20+
"INSERT INTO TodoItems (Title, IsCompleted) OUTPUT INSERTED.Id VALUES (@Title, @IsCompleted)", item);
21+
return Results.Created($"/todo/{id}", new { Id = id });
22+
});
23+
24+
app.MapPut("/todo/{id}", async (SqlConnection conn, int id, TodoItem item) =>
25+
{
26+
var existingItem = await conn.QuerySingleOrDefaultAsync<TodoItem>("SELECT * FROM TodoItems WHERE Id = @Id", new { Id = id });
27+
if (existingItem == null)
28+
return Results.NotFound();
29+
30+
existingItem.Title = item.Title;
31+
existingItem.IsCompleted = item.IsCompleted;
32+
33+
await conn.ExecuteAsync("UPDATE TodoItems SET Title = @Title, IsCompleted = @IsCompleted WHERE Id = @Id", existingItem);
34+
return Results.NoContent();
35+
});
36+
37+
app.MapDelete("/todo/{id}", async (SqlConnection conn, int id) =>
38+
{
39+
var existingItem = await conn.QuerySingleOrDefaultAsync<TodoItem>("SELECT * FROM TodoItems WHERE Id = @Id", new { Id = id });
40+
if (existingItem == null)
41+
return Results.NotFound();
42+
43+
await conn.ExecuteAsync("DELETE FROM TodoItems WHERE Id = @Id", new { Id = id });
44+
return Results.NoContent();
45+
});
46+
}
47+
}

0 commit comments

Comments
 (0)