diff --git a/CommBank-Server/CommBank.csproj b/CommBank-Server/CommBank.csproj index 983cc882..2023faf9 100644 --- a/CommBank-Server/CommBank.csproj +++ b/CommBank-Server/CommBank.csproj @@ -1,7 +1,7 @@ - net6.0 + net9.0 enable enable CommBank_Server diff --git a/CommBank-Server/Controllers/GoalController.cs b/CommBank-Server/Controllers/GoalController.cs index 98271a5f..b8eb26f7 100644 --- a/CommBank-Server/Controllers/GoalController.cs +++ b/CommBank-Server/Controllers/GoalController.cs @@ -70,19 +70,20 @@ public async Task Post(Goal newGoal) [HttpPut("{id:length(24)}")] public async Task Update(string id, Goal updatedGoal) - { - var goal = await _goalsService.GetAsync(id); + { + // var goal = await _goalsService.GetAsync(id); - if (goal is null) - { - return NotFound(); - } + // if (goal is null) + // { + // return NotFound(); + // } - updatedGoal.Id = goal.Id; + // updatedGoal.Id = goal.Id; - await _goalsService.UpdateAsync(id, updatedGoal); + // await _goalsService.UpdateAsync(id, updatedGoal); - return NoContent(); + // return NoContent(); + return Ok(updatedGoal); } [HttpDelete("{id:length(24)}")] diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..20b9b5d4 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -27,4 +27,6 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } + + public string? Icon { get; set; } } \ No newline at end of file diff --git a/CommBank-Server/Program.cs b/CommBank-Server/Program.cs index a88e560d..a2c2022c 100644 --- a/CommBank-Server/Program.cs +++ b/CommBank-Server/Program.cs @@ -2,6 +2,9 @@ using CommBank.Services; using MongoDB.Driver; +System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls13; + + var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json index 0e5bf949..8aba59ea 100644 --- a/CommBank-Server/Secrets.json +++ b/CommBank-Server/Secrets.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" + "CommBank": "mongodb+srv://rohitsaindane36_db_user:f3SL0rC8lE5pfehX@cluster0.il9cio6.mongodb.net/?appName=Cluster0" } } \ No newline at end of file diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..c65f7fc6 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -66,9 +66,28 @@ public async void Get() public async void GetForUser() { // Arrange - - // Act - + + var goals = collections.GetGoals(); + var users = collections.GetUsers(); + IGoalsService goalsService = new FakeGoalsService(goals, goals[0]); + IUsersService usersService = new FakeUsersService(users, users[0]); + GoalController controller = new(goalsService, usersService); + + var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext(); + controller.ControllerContext.HttpContext = httpContext; + + + //Act + var result = await controller.GetForUser(users[0].Id!); + + // Assert + + Assert.NotNull(result); + foreach (Goal goal in result) + { + Assert.IsAssignableForm(goal); + Assert.Equal(goals[0].UserId, goal.UserId); + } } } \ No newline at end of file