using System; using Amazon.DynamoDBv2; using Amazon.Lambda.Core; using Amazon.XRay.Recorder.Handlers.AwsSdk; using Plagiarism; using PlagiarismRepository; // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] namespace ResolveIncidentTask { public class Function { private readonly IIncidentRepository _incidentRepository; public Function() { AWSSDKHandler.RegisterXRayForAllServices(); _incidentRepository = new IncidentRepository(Environment.GetEnvironmentVariable("TABLE_NAME")); } /// /// Constructor used for testing purposes /// /// Instance of DynamoDB client /// DynamoDB table name public Function(IAmazonDynamoDB ddbClient, string tablename) { AWSSDKHandler.RegisterXRayForAllServices(); _incidentRepository = new IncidentRepository(ddbClient, tablename); } /// /// Function to resolve the incident and cpmplete the workflow. /// All state data is persisted. /// /// /// /// public void FunctionHandler(Incident incident, ILambdaContext context) { incident.AdminActionRequired = false; incident.IncidentResolved = true; incident.ResolutionDate = DateTime.Now; _incidentRepository.SaveIncident(incident); } } }