diff --git a/CommBank-Server/Controllers/GoalController.cs b/CommBank-Server/Controllers/GoalController.cs index 98271a5f..d0b9b71b 100644 --- a/CommBank-Server/Controllers/GoalController.cs +++ b/CommBank-Server/Controllers/GoalController.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using CommBank.Services; using CommBank.Models; @@ -69,7 +69,7 @@ public async Task Post(Goal newGoal) } [HttpPut("{id:length(24)}")] - public async Task Update(string id, Goal updatedGoal) + public async Task Update(string id, UpdatedIcon updatedIcon) { var goal = await _goalsService.GetAsync(id); @@ -78,9 +78,9 @@ public async Task 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(); } diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..13af77a3 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,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/Models/UpdatedIcon.cs b/CommBank-Server/Models/UpdatedIcon.cs index 9b3602f2..d801906d 100644 --- a/CommBank-Server/Models/UpdatedIcon.cs +++ b/CommBank-Server/Models/UpdatedIcon.cs @@ -1,4 +1,4 @@ -namespace CommBank.Models; +namespace CommBank.Models; interface IUpdatedIcon { @@ -8,6 +8,11 @@ interface IUpdatedIcon public class UpdatedIcon : IUpdatedIcon { + public UpdatedIcon() + { + Icon = string.Empty; + } + public UpdatedIcon(string icon) { Icon = icon;