From 9c21219bdae6c57b47a222653951095ffc0cbbb8 Mon Sep 17 00:00:00 2001 From: Jaikiran1212 Date: Fri, 26 Jun 2026 15:02:34 +0530 Subject: [PATCH 1/2] Add optional Icon field to Goal model --- CommBank-Server/CommBank.csproj | 2 +- CommBank-Server/Models/Goal.cs | 5 +++-- CommBank-Server/Program.cs | 4 ++-- CommBank-Server/Secrets.json | 6 +++--- CommBank-Server/Services/GoalService.cs | 6 +++--- CommBank-Server/appsettings.json | 10 +++++++--- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CommBank-Server/CommBank.csproj b/CommBank-Server/CommBank.csproj index 983cc882..5d76d035 100644 --- a/CommBank-Server/CommBank.csproj +++ b/CommBank-Server/CommBank.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable CommBank_Server diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..15fe76ac 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -1,4 +1,4 @@ -using MongoDB.Bson; +using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; namespace CommBank.Models; @@ -27,4 +27,5 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } -} \ No newline at end of file + public string? Icon { get; set; } +} diff --git a/CommBank-Server/Program.cs b/CommBank-Server/Program.cs index a88e560d..24a3005d 100644 --- a/CommBank-Server/Program.cs +++ b/CommBank-Server/Program.cs @@ -1,4 +1,4 @@ -using CommBank.Models; +using CommBank.Models; using CommBank.Services; using MongoDB.Driver; @@ -12,7 +12,7 @@ builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("Secrets.json"); var mongoClient = new MongoClient(builder.Configuration.GetConnectionString("CommBank")); -var mongoDatabase = mongoClient.GetDatabase("CommBank"); +var mongoDatabase = mongoClient.GetDatabase("commbank"); IAccountsService accountsService = new AccountsService(mongoDatabase); IAuthService authService = new AuthService(mongoDatabase); diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json index 0e5bf949..64283a34 100644 --- a/CommBank-Server/Secrets.json +++ b/CommBank-Server/Secrets.json @@ -1,5 +1,5 @@ -{ +{ "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" + "CommBank": "mongodb+srv://jaikiranjp_db_user:8hU5jpA1Q9KsGop5@commbank.8tvgsl4.mongodb.net/?retryWrites=true&w=majority&appName=commbank" } -} \ No newline at end of file +} diff --git a/CommBank-Server/Services/GoalService.cs b/CommBank-Server/Services/GoalService.cs index b0c600a1..2eacda91 100644 --- a/CommBank-Server/Services/GoalService.cs +++ b/CommBank-Server/Services/GoalService.cs @@ -1,4 +1,4 @@ -using CommBank.Models; +using CommBank.Models; using MongoDB.Driver; namespace CommBank.Services; @@ -9,7 +9,7 @@ public class GoalsService : IGoalsService public GoalsService(IMongoDatabase mongoDatabase) { - _goalsCollection = mongoDatabase.GetCollection("Goals"); + _goalsCollection = mongoDatabase.GetCollection("goals"); } public async Task> GetAsync() => @@ -29,4 +29,4 @@ public async Task UpdateAsync(string id, Goal updatedGoal) => public async Task RemoveAsync(string id) => await _goalsCollection.DeleteOneAsync(x => x.Id == id); -} \ No newline at end of file +} diff --git a/CommBank-Server/appsettings.json b/CommBank-Server/appsettings.json index af0538f7..e557f410 100644 --- a/CommBank-Server/appsettings.json +++ b/CommBank-Server/appsettings.json @@ -5,6 +5,10 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" -} - + "AllowedHosts": "*", + "GoalDatabaseSettings": { + "ConnectionString": "mongodb+srv://jaikiranjp_db_user:8hU5jpA1Q9KsGop5@commbank.8tvgsl4.mongodb.net/?retryWrites=true&w=majority&appName=commbank", + "DatabaseName": "commbank", + "GoalsCollectionName": "goals" + } +} \ No newline at end of file From 4d391324d787f461ad4ead47a50a826f3c780b7a Mon Sep 17 00:00:00 2001 From: Jaikiran1212 Date: Fri, 26 Jun 2026 15:43:15 +0530 Subject: [PATCH 2/2] Add GetForUser test to GoalControllerTests --- CommBank.Tests/CommBank.Tests.csproj | 2 +- CommBank.Tests/GoalControllerTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CommBank.Tests/CommBank.Tests.csproj b/CommBank.Tests/CommBank.Tests.csproj index 4d9413f4..3da571e3 100644 --- a/CommBank.Tests/CommBank.Tests.csproj +++ b/CommBank.Tests/CommBank.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..72ab81b8 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -1,4 +1,4 @@ -using CommBank.Controllers; +using CommBank.Controllers; using CommBank.Services; using CommBank.Models; using CommBank.Tests.Fake; @@ -71,4 +71,4 @@ public async void GetForUser() // Assert } -} \ No newline at end of file +}