Skip to content

Commit

Permalink
Updated POST route to use authenticated user credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Centerville1 committed Nov 12, 2024
1 parent b8ac934 commit 91dcd10
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Gordon360/Controllers/LostAndFoundController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public class LostAndFoundController(CCTContext context, ILostAndFoundService los
[Route("missingitem")]
public ActionResult<int> CreateMissingItemReport([FromBody] MissingItemReportViewModel MissingItemDetails)
{
int ID = lostAndFoundService.CreateMissingItemReport(MissingItemDetails);
var authenticatedUserUsername = AuthUtils.GetUsername(User);

int ID = lostAndFoundService.CreateMissingItemReport(MissingItemDetails, authenticatedUserUsername);

return Ok(ID);
}
Expand Down
4 changes: 2 additions & 2 deletions Gordon360/Services/LostAndFoundService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ namespace Gordon360.Services
{
public class LostAndFoundService(CCTContext context) : ILostAndFoundService
{
public int CreateMissingItemReport(MissingItemReportViewModel reportDetails)
public int CreateMissingItemReport(MissingItemReportViewModel reportDetails, string username)
{

var account = context.ACCOUNT.FirstOrDefault(x => x.AD_Username == reportDetails.submitterUsername);
var account = context.ACCOUNT.FirstOrDefault(x => x.AD_Username == username);

string idNum;

Expand Down
2 changes: 1 addition & 1 deletion Gordon360/Services/ServiceInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public interface IHousingService

public interface ILostAndFoundService
{
public int CreateMissingItemReport(MissingItemReportViewModel reportDetails);
public int CreateMissingItemReport(MissingItemReportViewModel reportDetails, string username);
IEnumerable<MissingItemReportViewModel> GetMissingItems(string username);
IEnumerable<MissingItemReportViewModel> GetMissingItemsAll();
IEnumerable<FoundItems> GetFoundItems();
Expand Down

0 comments on commit 91dcd10

Please sign in to comment.