public IActionResult CreateTreatment([FromBody] CreateTreatmentViewModel createTreatment) { var treatmentDTO = TreatmentMapper.CreateTreatmentVMToDTO(createTreatment); _service.Create(treatmentDTO); return(Ok(ModelState)); }
public Risk CreateRisk(CreateRiskCommand command) { var newValue = _riskService.Create(command).Result; _relationshipService.Create(new CreateRelationshipCommand() { FromType = ObjectType.Asset, FromId = command.AssetId, ToType = ObjectType.Risk, ToId = newValue.Id }); foreach (var item in command.Vulnerabilities) { _relationshipService.Create(new CreateRelationshipCommand() { FromType = ObjectType.Risk, FromId = newValue.Id, ToType = ObjectType.Vulnerabilitie, ToId = item }); } foreach (var item in command.Risks) { _relationshipService.Create(new CreateRelationshipCommand() { FromType = ObjectType.Risk, FromId = newValue.Id, ToType = ObjectType.Risk, ToId = item }); } foreach (var item in command.Treatments) { var treatment = _treatmentService.Create(new CreateTreatmentCommand() { RiskId = newValue.Id, Name = item.Name, Description = item.Description, Type = item.Type }).Result; _relationshipService.Create(new CreateRelationshipCommand() { FromType = ObjectType.Asset, ToType = ObjectType.TreatmentPayload, FromId = command.AssetId, ToId = treatment.Payload.Id }); } _auditTrailService.LogAction(AuditTrailAction.CreateRisk, newValue.Id, new AuditTrailPayloadModel() { Data = JsonConvert.SerializeObject(command) }); return(newValue); }
public async Task <IActionResult> CreateTreatment([FromBody] CreateTreatmentCommand command) { var newValue = await _treatmentService.Create(command); _relationshipService.Create(new CreateRelationshipCommand() { FromType = ObjectType.Asset, FromId = command.AssetId, ToType = ObjectType.Treatment, ToId = newValue.Id }); _relationshipService.Create(new CreateRelationshipCommand() { FromType = ObjectType.Risk, FromId = command.RiskId, ToType = ObjectType.Treatment, ToId = newValue.Id }); _auditTrailService.LogAction(AuditTrailAction.CreateTreatment, newValue.Id, new AuditTrailPayloadModel() { Data = JsonConvert.SerializeObject(command) }); return(Created(newValue.Id.ToString(), newValue)); }
public Treatment CreateTreatment(CreateTreatmentCommand command) { var newValue = _treatmentService.Create(command).Result; _relationshipService.Create(new CreateRelationshipCommand() { FromType = _assetService.GetSingle(x => x.Id == command.AssetId) != null ? ObjectType.Asset : ObjectType.AssetEdge, FromId = command.AssetId, ToType = ObjectType.TreatmentPayload, ToId = newValue.Payload.Id, CreateByUserId = command.CreateByUserId }); _auditTrailService.LogAction(AuditTrailAction.CreateTreatment, newValue.Id, new AuditTrailPayloadModel() { Data = JsonConvert.SerializeObject(command) }); return(newValue); }