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
8 changes: 4 additions & 4 deletions CommBank-Server/Controllers/GoalController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using CommBank.Services;
using CommBank.Models;

Expand Down Expand Up @@ -69,7 +69,7 @@ public async Task<IActionResult> Post(Goal newGoal)
}

[HttpPut("{id:length(24)}")]
public async Task<IActionResult> Update(string id, Goal updatedGoal)
public async Task<IActionResult> Update(string id, UpdatedIcon updatedIcon)
{
var goal = await _goalsService.GetAsync(id);

Expand All @@ -78,9 +78,9 @@ public async Task<IActionResult> Update(string id, Goal updatedGoal)
return NotFound();
}

updatedGoal.Id = goal.Id;
goal.Icon = updatedIcon.Icon;

await _goalsService.UpdateAsync(id, updatedGoal);
await _goalsService.UpdateAsync(id, goal);

return NoContent();
}
Expand Down
4 changes: 3 additions & 1 deletion CommBank-Server/Models/Goal.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MongoDB.Bson;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace CommBank.Models;
Expand Down Expand Up @@ -27,4 +27,6 @@ public class Goal

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

public string? Icon { get; set; }
}
7 changes: 6 additions & 1 deletion CommBank-Server/Models/UpdatedIcon.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CommBank.Models;
namespace CommBank.Models;

interface IUpdatedIcon
{
Expand All @@ -8,6 +8,11 @@ interface IUpdatedIcon

public class UpdatedIcon : IUpdatedIcon
{
public UpdatedIcon()
{
Icon = string.Empty;
}

public UpdatedIcon(string icon)
{
Icon = icon;
Expand Down