Skip to content

Commit

Permalink
Add the inspectionfindings table back
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUsama-afk-equinor committed Nov 15, 2023
1 parent 8da0faa commit d21230e
Show file tree
Hide file tree
Showing 10 changed files with 1,464 additions and 31 deletions.
8 changes: 4 additions & 4 deletions backend/api/Controllers/InspectionFindingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ IInspectionService inspectionService
/// </summary>
/// <remarks>
/// </remarks>
/* [HttpPost("add-findings")]
[HttpPost("add-findings")]
[Authorize(Roles = Role.Admin)]
[ProducesResponseType(typeof(InspectionFindings), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(InspectionFinding), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<InspectionFindings>> AddFindings([FromBody] InspectionFindingsQuery inspectionFinding)
public async Task<ActionResult<InspectionFinding>> AddFindings([FromBody] InspectionFindingsQuery inspectionFinding)
{
_logger.LogInformation("Updating inspection findings for inspection with isarStepId '{Id}'", inspectionFinding.IsarStepId);
try
Expand Down Expand Up @@ -89,7 +89,7 @@ public async Task<ActionResult<Inspection>> GetInspections([FromRoute] string id
}
return NotFound("Could not find any inspection with the provided '{id}'");
}
*/

}


Expand Down
4 changes: 2 additions & 2 deletions backend/api/Database/Context/FlotillaDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
);
});
/*modelBuilder.Entity<Inspection>(inspectionEntity =>
modelBuilder.Entity<Inspection>(inspectionEntity =>
{
if (isSqlLite) { AddConverterForDateTimeOffsets(ref inspectionEntity); }
inspectionEntity.OwnsMany(i => i.InspectionFindings);
});
*/

modelBuilder.Entity<MissionDefinition>()
.Property(m => m.InspectionFrequency)
.HasConversion(new TimeSpanToTicksConverter());
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Database/Models/Inspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ or InspectionStatus.Successful

public DateTime? EndTime { get; private set; }

//public List<InspectionFindings> InspectionFindings { get; set; }
public List<InspectionFinding> InspectionFindings { get; set; }

public void UpdateWithIsarInfo(IsarStep isarStep)
{
Expand Down
38 changes: 38 additions & 0 deletions backend/api/Database/Models/InspectionFinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Api.Controllers.Models;
#pragma warning disable CS8618
namespace Api.Database.Models
{
public class InspectionFinding
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }

public DateTime InspectionDate { get; set; }

public string Area { get; set; }

public string IsarStepId { get; set; }

public string Findings { get; set; }

public InspectionFinding(InspectionFindingsQuery createInspectionFindingQuery)
{
InspectionDate = createInspectionFindingQuery.InspectionDate;
Area = createInspectionFindingQuery.Area;
IsarStepId = createInspectionFindingQuery.IsarStepId;
Findings = createInspectionFindingQuery.Findings;
}

public InspectionFinding()
{
InspectionDate = DateTime.UtcNow;
Area = "string";
IsarStepId = "string";
Findings = "string";
}
}

}
Loading

0 comments on commit d21230e

Please sign in to comment.