Skip to content

Commit

Permalink
Remove response file for inspectionfindings
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUsama-afk-equinor authored and UsamaEquinorAFK committed Nov 15, 2023
1 parent d390101 commit f63ac1e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 51 deletions.
26 changes: 13 additions & 13 deletions backend/api/Controllers/InspectionFindingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ IInspectionService inspectionService
/// </remarks>
[HttpPost("add-findings")]
[Authorize(Roles = Role.Admin)]
[ProducesResponseType(typeof(InspectionFindingsResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(InspectionFindings), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<InspectionFindingsResponse>> AddFindings([FromBody] InspectionFindingsQuery inspectionFinding)
public async Task<ActionResult<InspectionFindings>> AddFindings([FromBody] InspectionFindingsQuery inspectionFinding)
{
_logger.LogInformation("Updating inspection findings for inspection with isarStepId '{Id}'", inspectionFinding.IsarStepId);
try
{
var inspection = await _inspectionService.ReadByIsarStepId(inspectionFinding.IsarStepId);
var inspection = await _inspectionService.AddFindings(inspectionFinding);

if (inspection != null)
{
inspection = await _inspectionService.AddFindings(inspectionFinding);
return Ok(inspection);
return Ok(inspection.InspectionFindings);
}

}
catch (Exception e)
{
_logger.LogError(e, "Error while adding findings to inspection with IsarStepId '{inspectionFinding.IsarStepId}'", inspectionFinding.IsarStepId);
throw;
_logger.LogError(e, "Error while adding findings to inspection with IsarStepId '{Id}'", inspectionFinding.IsarStepId);
return StatusCode(StatusCodes.Status500InternalServerError);
}
return NotFound();
return NotFound($"Could not find any inspection with the provided '{inspectionFinding.IsarStepId}'");
}

/// <summary>
Expand All @@ -64,15 +64,15 @@ public async Task<ActionResult<InspectionFindingsResponse>> AddFindings([FromBod
[HttpGet]
[Authorize(Roles = Role.Admin)]
[Route("{id}")]
[ProducesResponseType(typeof(AreaResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(Inspection), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<InspectionFindings>> GetInspections([FromRoute] string id)
public async Task<ActionResult<Inspection>> GetInspections([FromRoute] string id)
{
_logger.LogInformation("Get inspection by ID '{inspectionFinding.InspectionId}'", id);
_logger.LogInformation("Get inspection by ID '{id}'", id);
try
{
var inspection = await _inspectionService.ReadByIsarStepId(id);
Expand All @@ -85,9 +85,9 @@ public async Task<ActionResult<InspectionFindings>> GetInspections([FromRoute] s
catch (Exception e)
{
_logger.LogError(e, "Error while finding an inspection with inspection id '{id}'", id);
throw;
return StatusCode(StatusCodes.Status500InternalServerError);
}
return NotFound();
return NotFound("Could not find any inspection with the provided '{id}'");
}

}
Expand Down
4 changes: 1 addition & 3 deletions backend/api/Controllers/Models/InspectionFindingsQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
public struct InspectionFindingsQuery
{

public string RobotName { get; set; }

public string InspectionDate { get; set; }
public DateTime InspectionDate { get; set; }

public string Area { get; set; }

Expand Down
28 changes: 0 additions & 28 deletions backend/api/Controllers/Models/InspectionFindingsResponse.cs

This file was deleted.

8 changes: 2 additions & 6 deletions backend/api/Database/Models/InspectionFindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ public class InspectionFindings
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }

public string RobotName { get; set; }

public string InspectionDate { get; set; }
public DateTime InspectionDate { get; set; }

public string Area { get; set; }

Expand All @@ -22,7 +20,6 @@ public class InspectionFindings

public InspectionFindings(InspectionFindingsQuery createInspectionFindingQuery)
{
RobotName = createInspectionFindingQuery.RobotName;
InspectionDate = createInspectionFindingQuery.InspectionDate;
Area = createInspectionFindingQuery.Area;
IsarStepId = createInspectionFindingQuery.IsarStepId;
Expand All @@ -31,8 +28,7 @@ public InspectionFindings(InspectionFindingsQuery createInspectionFindingQuery)

public InspectionFindings()
{
RobotName = "string";
InspectionDate = "string";
InspectionDate = DateTime.UtcNow;
Area = "string";
IsarStepId = "string";
Findings = "string";
Expand Down
1 change: 0 additions & 1 deletion backend/api/Services/InspectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ private IQueryable<Inspection> GetInspections()

var inspectionFindings = new InspectionFindings
{
RobotName = inspectionFindingsQuery.RobotName,
InspectionDate = inspectionFindingsQuery.InspectionDate,
Area = inspectionFindingsQuery.Area,
IsarStepId = inspectionFindingsQuery.IsarStepId,
Expand Down

0 comments on commit f63ac1e

Please sign in to comment.