Skip to content

Commit

Permalink
Added GetImagePathOfAttendee HTTP method.
Browse files Browse the repository at this point in the history
  • Loading branch information
kalrit718 committed Apr 28, 2022
1 parent 0c23f42 commit 5204ad2
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 0 deletions.
Binary file modified .vs/ProjectMOFI_Server_WebAPI/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/ProjectMOFI_Server_WebAPI/v17/.suo
Binary file not shown.
17 changes: 17 additions & 0 deletions Controllers/AttendeeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ public async Task<IActionResult> GetAttendeeById(string id) {
return StatusCode(500, "[ERROR]- An unexpected error occured!");
}
}

[HttpGet("{id}/ImagePath")]
public async Task<IActionResult> GetImagePathOfAttendee(string id) {
try {
if (string.IsNullOrWhiteSpace(id)) {
return BadRequest();
}
return await Task.FromResult(Ok(_connection.LoadUserImagePathById(id)));
}
catch (ArgumentException ex) {
return StatusCode(404, ex.Message);
}
catch (Exception ex) {
Console.WriteLine(ex.StackTrace);
return StatusCode(500, "[ERROR]- An unexpected error occured!");
}
}

[HttpPost]
public async Task<IActionResult> PostAttendee(Attendee newAttendee) {
Expand Down
12 changes: 12 additions & 0 deletions MongoDB/MongoConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,17 @@ public List<AttendanceRecord> LoadAttendaceRecords() {
generatedList.Sort(new SortAttendanceRecordsByDateComparer());
return generatedList;
}

public string LoadUserImagePathById(string id) {
var collection = db.GetCollection<Attendee>(userCollectionName);
var filter = Builders<Attendee>.Filter.Eq("Id", id);

if (collection.Find(filter).Any()) {
return collection.Find(filter).First().ImagePath;
}
else {
throw new ArgumentException("[ERROR] - Invalid ID provided.");
}
}
}
}
Binary file modified bin/Debug/net6.0/ProjectMOFI_Server_WebAPI.dll
Binary file not shown.
Binary file modified bin/Debug/net6.0/ProjectMOFI_Server_WebAPI.pdb
Binary file not shown.
Binary file modified bin/Debug/net6.0/ref/ProjectMOFI_Server_WebAPI.dll
Binary file not shown.
Binary file not shown.
Binary file modified obj/Debug/net6.0/ProjectMOFI_Server_WebAPI.dll
Binary file not shown.
Binary file modified obj/Debug/net6.0/ProjectMOFI_Server_WebAPI.pdb
Binary file not shown.
Binary file modified obj/Debug/net6.0/ref/ProjectMOFI_Server_WebAPI.dll
Binary file not shown.
1 change: 1 addition & 0 deletions obj/staticwebassets.pack.sentinel
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@
2.0
2.0
2.0
2.0

0 comments on commit 5204ad2

Please sign in to comment.