Skip to content

Commit

Permalink
actionsTaken post request
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-1010 committed Nov 14, 2024
1 parent 91dcd10 commit 83cd3cf
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Gordon360/Controllers/LostAndFoundController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Gordon360.Services;
using Gordon360.Static.Names;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand All @@ -31,6 +32,20 @@ public ActionResult<int> CreateMissingItemReport([FromBody] MissingItemReportVie
return Ok(ID);
}

/// <summary>
/// Create action taken of the missing item report with actions taken object and missing item report ID
/// </summary>
/// <param name="id">The id of the report to update</param>
/// <returns>ObjectResult - the http status code result of the action</returns>
[HttpPost]
[Route("missingitem/{id}/actionTaken")]
public ActionResult<int> CreateActionTaken(int id, [FromBody] ActionsTaken ActionsTaken)
{
int ID = lostAndFoundService.CreateActionTaken(id, ActionsTaken);

return Ok(ID);
}

/// <summary>
/// Update Missing Item Report with the given id with given data
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions Gordon360/Documentation/Gordon360.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions Gordon360/Services/LostAndFoundService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;


Expand Down Expand Up @@ -80,6 +81,30 @@ public int CreateMissingItemReport(MissingItemReportViewModel reportDetails, str
return reportID;
}

/// <param name="id">The id</param>
public int CreateActionTaken(int id, ActionsTaken ActionsTaken)
{
var newActionTaken = context.ActionsTaken.Add(new ActionsTaken
{
missingID = ActionsTaken.missingID,
action = ActionsTaken.action,
actionNote = ActionsTaken.actionNote,
actionDate = ActionsTaken.actionDate,
submitterID = ActionsTaken.submitterID,
});

context.SaveChangesAsync();

if (newActionTaken == null || newActionTaken?.Entity?.ID == 0)
{
throw new ResourceCreationException() { ExceptionMessage = "The report could not be saved." };
}

int actionTakenID = newActionTaken.Entity.ID;

return actionTakenID;
}

/// <param name="id">The id</param>
public async Task UpdateMissingItemReportAsync(int id, MissingItemReportViewModel reportDetails)
{
Expand Down
1 change: 1 addition & 0 deletions Gordon360/Services/ServiceInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public interface IHousingService
public interface ILostAndFoundService
{
public int CreateMissingItemReport(MissingItemReportViewModel reportDetails, string username);
public int CreateActionTaken(int id, ActionsTaken ActionsTaken);
IEnumerable<MissingItemReportViewModel> GetMissingItems(string username);
IEnumerable<MissingItemReportViewModel> GetMissingItemsAll();
IEnumerable<FoundItems> GetFoundItems();
Expand Down

0 comments on commit 83cd3cf

Please sign in to comment.