-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cb2-8661): remove validation as moved to earlier step (#329)
* feat(cb2-8661): remove validation as moved to earlier step * feat(cb2-8661): remove old int test
- Loading branch information
1 parent
98169eb
commit ed20491
Showing
4 changed files
with
182 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
import TechRecordsDAO from "../models/TechRecordsDAO"; | ||
import TechRecordsService from "../services/TechRecordsService"; | ||
import HTTPResponse from "../models/HTTPResponse"; | ||
import {STATUS, HTTPRESPONSE} from "../assets/Enums"; | ||
import {TechRecordStatusHandler} from "../handlers/TechRecordStatusHandler"; | ||
import { STATUS, HTTPRESPONSE } from "../assets/Enums"; | ||
import { TechRecordStatusHandler } from "../handlers/TechRecordStatusHandler"; | ||
|
||
export async function updateTechRecordStatus(event: any) { | ||
const techRecordsService = new TechRecordsService(new TechRecordsDAO()); | ||
const techRecordsService = new TechRecordsService(new TechRecordsDAO()); | ||
|
||
const systemNumber: string = event.pathParameters.systemNumber; | ||
const testStatus: string = event.queryStringParameters!.testStatus; | ||
const testResult: string = event.queryStringParameters!.testResult; | ||
const testTypeId: string = event.queryStringParameters!.testTypeId; | ||
const newStatus = event.queryStringParameters ? STATUS[event.queryStringParameters.newStatus as keyof typeof STATUS] : undefined; | ||
const createdById: string = event.queryStringParameters!.createdById; | ||
const createdByName: string = event.queryStringParameters!.createdByName; | ||
const systemNumber: string = event.pathParameters.systemNumber; | ||
const testStatus: string = event.queryStringParameters!.testStatus; | ||
const testResult: string = event.queryStringParameters!.testResult; | ||
const testTypeId: string = event.queryStringParameters!.testTypeId; | ||
const newStatus = event.queryStringParameters | ||
? STATUS[event.queryStringParameters.newStatus as keyof typeof STATUS] | ||
: undefined; | ||
const createdById: string = event.queryStringParameters!.createdById; | ||
const createdByName: string = event.queryStringParameters!.createdByName; | ||
|
||
if (!TechRecordStatusHandler.isStatusUpdateRequired(testStatus, testResult, testTypeId)) { | ||
return new HTTPResponse(200, HTTPRESPONSE.NO_STATUS_UPDATE_REQUIRED); | ||
} | ||
try { | ||
const updatedTechRec = await techRecordsService.updateTechRecordStatusCode(systemNumber, newStatus, createdById, createdByName); | ||
return new HTTPResponse(200, updatedTechRec); | ||
} catch (error) { | ||
return new HTTPResponse(error.statusCode, error.body); | ||
} | ||
try { | ||
const updatedTechRec = await techRecordsService.updateTechRecordStatusCode( | ||
systemNumber, | ||
newStatus, | ||
createdById, | ||
createdByName | ||
); | ||
return new HTTPResponse(200, updatedTechRec); | ||
} catch (error) { | ||
return new HTTPResponse(error.statusCode, error.body); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.