Skip to content

Commit 1c1f704

Browse files
committed
refactor: remove unused Docker setup and update backend to .NET 8.0
1 parent 53f6590 commit 1c1f704

File tree

17 files changed

+101
-220
lines changed

17 files changed

+101
-220
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
"customizations": {
4141
"vscode": {
4242
"extensions": [
43-
"humao.rest-client"
43+
"humao.rest-client",
44+
"GitHub.copilot-chat",
45+
"ms-dotnettools.csdevkit"
4446
]
4547
}
4648
}

01-contenedores/contenedores-vi/stacks/stackdemo/Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

01-contenedores/contenedores-vi/stacks/stackdemo/app.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

01-contenedores/contenedores-vi/stacks/stackdemo/docker-compose.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

01-contenedores/contenedores-vi/stacks/stackdemo/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 44 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,68 @@
1-
using System.Collections.Generic;
2-
using backend.Models;
1+
using backend.Models;
32
using backend.Service;
43
using Microsoft.AspNetCore.Mvc;
54

6-
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
5+
namespace backend.Controllers;
76

8-
namespace backend.Controllers
7+
[Route("api/[controller]")]
8+
[ApiController]
9+
public class TopicsController(TopicService topicService) : ControllerBase
910
{
10-
[Route("api/[controller]")]
11-
[ApiController]
12-
public class TopicsController : ControllerBase
11+
// GET: api/topics
12+
[HttpGet]
13+
public IEnumerable<Topic> Get() => topicService.Get();
14+
15+
// GET api/topics/{id}
16+
[HttpGet("{id:length(24)}", Name = "GetTopic")]
17+
public ActionResult<Topic> Get(string id)
1318
{
14-
private readonly TopicService _topicService;
19+
var topic = topicService.Get(id);
1520

16-
public TopicsController(TopicService topicService)
21+
if (topic == null)
1722
{
18-
_topicService = topicService;
23+
return NotFound();
1924
}
2025

21-
// GET: api/<TopicsController>
22-
[HttpGet]
23-
public IEnumerable<Topic> Get() => _topicService.Get();
24-
25-
26-
// GET api/<TopicsController>/5
27-
[HttpGet("{id:length(24)}", Name = "GetTopic")]
28-
public ActionResult<Topic> Get(string id)
29-
{
30-
var topic = _topicService.Get(id);
26+
return topic;
27+
}
3128

32-
if (topic == null)
33-
{
34-
return NotFound();
35-
}
29+
// POST api/topics
30+
[HttpPost]
31+
public ActionResult<Topic> Create(Topic topic)
32+
{
33+
topicService.Create(topic);
34+
return CreatedAtRoute("GetTopic", new { id = topic.Id }, topic);
35+
}
3636

37-
return topic;
38-
}
37+
// PUT api/topics/{id}
38+
[HttpPut("{id:length(24)}")]
39+
public IActionResult Update(string id, Topic topicIn)
40+
{
41+
var topic = topicService.Get(id);
3942

40-
// POST api/<TopicsController>
41-
[HttpPost]
42-
public ActionResult<Topic> Create(Topic topic)
43+
if (topic == null)
4344
{
44-
_topicService.Create(topic);
45-
46-
return topic;
45+
return NotFound();
4746
}
4847

49-
[HttpPut("{id:length(24)}")]
50-
public IActionResult Update(string id, Topic topicIn)
51-
{
52-
var topic = _topicService.Get(id);
53-
54-
if (topic == null)
55-
{
56-
return NotFound();
57-
}
48+
topicService.Update(id, topicIn);
5849

59-
_topicService.Update(id, topicIn);
50+
return NoContent();
51+
}
6052

61-
return NoContent();
62-
}
53+
// DELETE api/topics/{id}
54+
[HttpDelete("{id:length(24)}")]
55+
public IActionResult Delete(string id)
56+
{
57+
var topic = topicService.Get(id);
6358

64-
[HttpDelete("{id:length(24)}")]
65-
public IActionResult Delete(string id)
59+
if (topic == null)
6660
{
67-
var topic = _topicService.Get(id);
68-
69-
if (topic == null)
70-
{
71-
return NotFound();
72-
}
61+
return NotFound();
62+
}
7363

74-
_topicService.Remove(topic.Id);
64+
topicService.Remove(id);
7565

76-
return NoContent();
77-
}
66+
return NoContent();
7867
}
7968
}
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
using MongoDB.Bson.Serialization.Attributes;
2-
using MongoDB.Bson;
1+
using MongoDB.Bson;
2+
using MongoDB.Bson.Serialization.Attributes;
33

4-
namespace backend.Models
4+
namespace backend.Models;
5+
6+
public class Topic
57
{
6-
public class Topic
7-
{
8-
[BsonId]
9-
[BsonRepresentation(BsonType.ObjectId)]
10-
public string Id { get; set; }
8+
[BsonId]
9+
[BsonRepresentation(BsonType.ObjectId)]
10+
public string? Id { get; set; }
1111

12-
[BsonElement("Name")]
13-
public string TopicName { get; set; }
14-
}
12+
[BsonElement("Name")]
13+
public string TopicName { get; set; } = null!;
1514
}
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
namespace backend.Models
2-
{
1+
namespace backend.Models;
32

4-
public interface ITopicstoreDatabaseSettings
5-
{
6-
string TopicsCollectionName { get; set; }
7-
string ConnectionString { get; set; }
8-
string DatabaseName { get; set; }
9-
}
3+
public interface ITopicstoreDatabaseSettings
4+
{
5+
string TopicsCollectionName { get; set; }
6+
string ConnectionString { get; set; }
7+
string DatabaseName { get; set; }
8+
}
109

11-
public class TopicstoreDatabaseSettings : ITopicstoreDatabaseSettings
12-
{
13-
public string TopicsCollectionName { get; set; }
14-
public string ConnectionString { get; set; }
15-
public string DatabaseName { get; set; }
16-
}
10+
public class TopicstoreDatabaseSettings : ITopicstoreDatabaseSettings
11+
{
12+
public string TopicsCollectionName { get; set; } = null!;
13+
public string ConnectionString { get; set; } = null!;
14+
public string DatabaseName { get; set; } = null!;
1715
}
Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Hosting;
6-
using Microsoft.Extensions.Configuration;
7-
using Microsoft.Extensions.Hosting;
8-
using Microsoft.Extensions.Logging;
1+
using backend;
92

10-
namespace backend
11-
{
12-
public class Program
3+
Host.CreateDefaultBuilder(args)
4+
.ConfigureWebHostDefaults(webBuilder =>
135
{
14-
public static void Main(string[] args)
15-
{
16-
CreateHostBuilder(args).Build().Run();
17-
}
18-
19-
public static IHostBuilder CreateHostBuilder(string[] args) =>
20-
Host.CreateDefaultBuilder(args)
21-
.ConfigureWebHostDefaults(webBuilder =>
22-
{
23-
webBuilder.UseStartup<Startup>();
24-
});
25-
}
26-
}
6+
webBuilder.UseStartup<Startup>();
7+
})
8+
.Build()
9+
.Run();

01-contenedores/lemoncode-challenge/dotnet-stack/backend/Properties/launchSettings.json

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
{
22
"$schema": "http://json.schemastore.org/launchsettings.json",
3-
"iisSettings": {
4-
"windowsAuthentication": false,
5-
"anonymousAuthentication": true,
6-
"iisExpress": {
7-
"applicationUrl": "http://localhost:49704",
8-
"sslPort": 0
9-
}
10-
},
113
"profiles": {
12-
"IIS Express": {
13-
"commandName": "IISExpress",
14-
"launchBrowser": true,
15-
"launchUrl": "weatherforecast",
16-
"environmentVariables": {
17-
"ASPNETCORE_ENVIRONMENT": "Development"
18-
}
19-
},
20-
"backend": {
4+
"http": {
215
"commandName": "Project",
6+
"dotnetRunMessages": true,
227
"launchBrowser": true,
23-
"launchUrl": "weatherforecast",
8+
"launchUrl": "api/topics",
249
"applicationUrl": "http://localhost:5000",
2510
"environmentVariables": {
2611
"ASPNETCORE_ENVIRONMENT": "Development"

0 commit comments

Comments
 (0)