aboutsummaryrefslogtreecommitdiff
path: root/Backend/Api
diff options
context:
space:
mode:
Diffstat (limited to 'Backend/Api')
-rw-r--r--Backend/Api/Api/Controllers/PostController.cs18
-rw-r--r--Backend/Api/Api/Database/DatabaseConnection.cs1
-rw-r--r--Backend/Api/Api/Interfaces/IDatabaseConnection.cs1
-rw-r--r--Backend/Api/Api/Interfaces/IPostService.cs9
-rw-r--r--Backend/Api/Api/Program.cs1
-rw-r--r--Backend/Api/Api/Services/PostService.cs22
-rw-r--r--Backend/Api/Api/appsettings.json3
7 files changed, 54 insertions, 1 deletions
diff --git a/Backend/Api/Api/Controllers/PostController.cs b/Backend/Api/Api/Controllers/PostController.cs
new file mode 100644
index 0000000..4bac0e5
--- /dev/null
+++ b/Backend/Api/Api/Controllers/PostController.cs
@@ -0,0 +1,18 @@
+using Api.Interfaces;
+using Microsoft.AspNetCore.Mvc;
+
+// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
+
+namespace Api.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class PostController : ControllerBase
+ {
+ private readonly IPostService _postService;
+ public PostController(IPostService postService)
+ {
+ _postService = postService;
+ }
+ }
+}
diff --git a/Backend/Api/Api/Database/DatabaseConnection.cs b/Backend/Api/Api/Database/DatabaseConnection.cs
index 65f4f52..c2fea05 100644
--- a/Backend/Api/Api/Database/DatabaseConnection.cs
+++ b/Backend/Api/Api/Database/DatabaseConnection.cs
@@ -7,5 +7,6 @@ namespace Api.Database
public string ConnectionString { get; set; } = String.Empty;
public string DatabaseName { get; set; } = String.Empty;
public string UserCollectionName { get; set; } = String.Empty;
+ public string PostCollectionName { get; set; } = String.Empty;
}
}
diff --git a/Backend/Api/Api/Interfaces/IDatabaseConnection.cs b/Backend/Api/Api/Interfaces/IDatabaseConnection.cs
index 8938127..e3fc60c 100644
--- a/Backend/Api/Api/Interfaces/IDatabaseConnection.cs
+++ b/Backend/Api/Api/Interfaces/IDatabaseConnection.cs
@@ -5,5 +5,6 @@
string ConnectionString { get; set; }
string DatabaseName { get; set; }
string UserCollectionName { get; set; }
+ string PostCollectionName { get; set; }
}
}
diff --git a/Backend/Api/Api/Interfaces/IPostService.cs b/Backend/Api/Api/Interfaces/IPostService.cs
new file mode 100644
index 0000000..6c34e69
--- /dev/null
+++ b/Backend/Api/Api/Interfaces/IPostService.cs
@@ -0,0 +1,9 @@
+using Api.Models;
+
+namespace Api.Interfaces
+{
+ public interface IPostService
+ {
+ PostSend addPost(PostReceive post);
+ }
+} \ No newline at end of file
diff --git a/Backend/Api/Api/Program.cs b/Backend/Api/Api/Program.cs
index 6c96331..9b80f3c 100644
--- a/Backend/Api/Api/Program.cs
+++ b/Backend/Api/Api/Program.cs
@@ -22,6 +22,7 @@ builder.Services.AddSingleton<IMongoClient>(s =>
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IJwtService, JwtService>();
+builder.Services.AddScoped<IPostService,PostService>();
builder.Services.AddHttpContextAccessor();
diff --git a/Backend/Api/Api/Services/PostService.cs b/Backend/Api/Api/Services/PostService.cs
new file mode 100644
index 0000000..2a5e789
--- /dev/null
+++ b/Backend/Api/Api/Services/PostService.cs
@@ -0,0 +1,22 @@
+using Api.Interfaces;
+using Api.Models;
+using MongoDB.Driver;
+
+namespace Api.Services
+{
+ public class PostService : IPostService
+ {
+ private readonly MongoClient _client;
+ private readonly IMongoCollection<Post> _posts;
+ public PostService(IDatabaseConnection settings, IMongoClient mongoClient)
+ {
+ var database = mongoClient.GetDatabase(settings.DatabaseName);
+ _posts = database.GetCollection<Post>(settings.PostCollectionName);
+ }
+
+ public PostSend addPost(PostReceive post)
+ {
+ return null;
+ }
+ }
+}
diff --git a/Backend/Api/Api/appsettings.json b/Backend/Api/Api/appsettings.json
index 74cfa27..2be2426 100644
--- a/Backend/Api/Api/appsettings.json
+++ b/Backend/Api/Api/appsettings.json
@@ -15,7 +15,8 @@
"ConnectionString": "mongodb://127.0.0.1:27017/",
"DatabaseName": "Odyssey",
- "UserCollectionName": "users"
+ "UserCollectionName": "users",
+ "PostCollectionName": "posts"
},
"EmailCfg": {