Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CommBank-Server/CommBank.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>CommBank_Server</RootNamespace>
Expand Down
19 changes: 10 additions & 9 deletions CommBank-Server/Controllers/GoalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,20 @@ public async Task<IActionResult> Post(Goal newGoal)

[HttpPut("{id:length(24)}")]
public async Task<IActionResult> 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)}")]
Expand Down
2 changes: 2 additions & 0 deletions CommBank-Server/Models/Goal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public class Goal

[BsonRepresentation(BsonType.ObjectId)]
public string? UserId { get; set; }

public string? Icon { get; set; }
}
3 changes: 3 additions & 0 deletions CommBank-Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion CommBank-Server/Secrets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"CommBank": "{CONNECTION_STRING}"
"CommBank": "mongodb+srv://rohitsaindane36_db_user:f3SL0rC8lE5pfehX@cluster0.il9cio6.mongodb.net/?appName=Cluster0"
}
}
25 changes: 22 additions & 3 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(goal);
Assert.Equal(goals[0].UserId, goal.UserId);
}
}
}