Skip to content

Commit 0fe288f

Browse files
authored
Merge pull request #4477 from cisagov/feat/CSET-3029
Assessment upgrade now including feedback, comments, documents, observations and contacts
2 parents 2975452 + 48fa4b9 commit 0fe288f

File tree

5 files changed

+118
-10
lines changed

5 files changed

+118
-10
lines changed

CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Assessment/AssessmentBusiness.cs

Lines changed: 114 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ public void ConvertAssessment(int assessment_id, int original_id, string targetA
11351135
{
11361136
try
11371137
{
1138+
ConvertContacts(assessment_id, original_id);
11381139
JArray questionIds = null;
11391140

11401141
var rh = new ResourceHelper();
@@ -1176,24 +1177,131 @@ public void ConvertAssessment(int assessment_id, int original_id, string targetA
11761177
ComponentGuid = original_record.Component_Guid,
11771178
Reviewed = original_record.Reviewed,
11781179
QuestionType = original_record.Question_Type,
1179-
Is_Maturity = original_record.Is_Maturity ?? true
1180+
Is_Maturity = original_record.Is_Maturity ?? true,
1181+
Comment = original_record.Comment
11801182
};
1183+
11811184

11821185
var adminTabBusiness = new AdminTabBusiness(_context);
11831186
var mb = new MaturityBusiness(_context, _assessmentUtil, adminTabBusiness);
11841187
mb.StoreAnswer(assessment_id, answer);
1188+
1189+
var newAnswer = _context.ANSWER
1190+
.Where(x => x.Assessment_Id == assessment_id &&
1191+
x.Question_Or_Requirement_Id == newQuestionId)
1192+
.FirstOrDefault();
1193+
1194+
ConvertFindings(original_record.Answer_Id, newAnswer.Answer_Id, assessment_id);
1195+
ConvertDocuments(original_record.Answer_Id, newAnswer.Answer_Id);
1196+
11851197
}
1186-
// Hide draft assessment
1187-
var draft = _context.ASSESSMENT_CONTACTS
1188-
.Where(x => x.Assessment_Id == original_id)
1189-
.FirstOrDefault();
1190-
draft.UserId = null;
1198+
11911199
_context.SaveChanges();
11921200
}
11931201
catch (Exception exc)
11941202
{
11951203
NLog.LogManager.GetCurrentClassLogger().Error($"... {exc}");
11961204
}
11971205
}
1206+
1207+
public void ConvertFindings(int originalAnswerId, int answerId, int assessmentId)
1208+
{
1209+
var originalObservationList = _context.FINDING.Where(x => x.Answer_Id == originalAnswerId).ToList();
1210+
1211+
foreach (var finding in originalObservationList)
1212+
{
1213+
var newFinding = new FINDING()
1214+
{
1215+
Answer_Id = answerId,
1216+
Summary = finding.Summary,
1217+
Impact = finding.Impact,
1218+
Issue = finding.Issue,
1219+
Recommendations = finding.Recommendations,
1220+
Vulnerabilities = finding.Vulnerabilities,
1221+
Resolution_Date = finding.Resolution_Date,
1222+
Title = finding.Title,
1223+
Type = finding.Type,
1224+
Risk_Area = finding.Risk_Area,
1225+
Sub_Risk = finding.Sub_Risk,
1226+
Description = finding.Description,
1227+
Citations = finding.Citations,
1228+
ActionItems = finding.ActionItems,
1229+
Supp_Guidance = finding.Supp_Guidance
1230+
};
1231+
_context.FINDING.Add(newFinding);
1232+
_context.SaveChanges();
1233+
1234+
var findingId = newFinding.Finding_Id;
1235+
ConvertFindingContacts(finding.Finding_Id, findingId, assessmentId);
1236+
}
1237+
}
1238+
1239+
public void ConvertFindingContacts(int originalFindingId, int newFindingId, int assessmentId)
1240+
{
1241+
var originalObservationContacts = _context.FINDING_CONTACT.Where(x => x.Finding_Id == originalFindingId).ToList();
1242+
1243+
if (originalObservationContacts.Any())
1244+
{
1245+
foreach (var findingContact in originalObservationContacts)
1246+
{
1247+
var assessmentContact = _context.ASSESSMENT_CONTACTS.Where(x => x.Assessment_Contact_Id == findingContact.Assessment_Contact_Id).FirstOrDefault();
1248+
var newAssessmentContact = _context.ASSESSMENT_CONTACTS.Where(x => x.UserId == assessmentContact.UserId && x.Assessment_Id == assessmentId).FirstOrDefault();
1249+
_context.FINDING_CONTACT.Add(new FINDING_CONTACT()
1250+
{
1251+
Finding_Id = newFindingId,
1252+
Assessment_Contact_Id = newAssessmentContact.Assessment_Contact_Id
1253+
});
1254+
}
1255+
}
1256+
}
1257+
1258+
public void ConvertDocuments(int originalAnswerId, int answerId)
1259+
{
1260+
var documentRecord = _context.DOCUMENT_ANSWERS.Where(x => x.Answer_Id == originalAnswerId).ToList();
1261+
foreach (var document in documentRecord)
1262+
{
1263+
_context.DOCUMENT_ANSWERS.Add(new DOCUMENT_ANSWERS()
1264+
{
1265+
Document_Id = document.Document_Id,
1266+
Answer_Id = answerId
1267+
});
1268+
_context.SaveChanges();
1269+
}
1270+
}
1271+
1272+
public void ConvertContacts(int assessmentId, int originalId)
1273+
{
1274+
//Grab contact record from auto generated new assessment contact
1275+
var contactRecord = _context.ASSESSMENT_CONTACTS.Where(x => x.Assessment_Id == assessmentId).FirstOrDefault();
1276+
//Grab original contacts for assessment
1277+
var originalContactRecord = _context.ASSESSMENT_CONTACTS.Where(x => x.Assessment_Id == originalId).ToList();
1278+
foreach (var contact in originalContactRecord)
1279+
{
1280+
if (contact.UserId != contactRecord.UserId)
1281+
{
1282+
_context.ASSESSMENT_CONTACTS.Add(new ASSESSMENT_CONTACTS()
1283+
{
1284+
FirstName = contact.FirstName,
1285+
LastName = contact.LastName,
1286+
PrimaryEmail = contact.PrimaryEmail,
1287+
Assessment_Id = assessmentId,
1288+
AssessmentRoleId = contact.AssessmentRoleId,
1289+
Title = contact.Title,
1290+
Phone = contact.Phone,
1291+
Cell_Phone = contact.Cell_Phone,
1292+
Reports_To = contact.Reports_To,
1293+
Organization_Name = contact.Organization_Name,
1294+
Site_Name = contact.Site_Name,
1295+
Emergency_Communications_Protocol = contact.Emergency_Communications_Protocol,
1296+
Is_Site_Participant = contact.Is_Site_Participant,
1297+
Is_Primary_POC = contact.Is_Primary_POC,
1298+
Last_Q_Answered = contact.Last_Q_Answered,
1299+
UserId = contact.UserId,
1300+
Invited = contact.Invited
1301+
});
1302+
_context.SaveChanges();
1303+
}
1304+
}
1305+
}
11981306
}
11991307
}

CSETWebNg/src/assets/i18n/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@
10271027
"upgrade": "Upgrade",
10281028
"final": "to final version",
10291029
"convert": "Converting your assessment, this may take a few moments.",
1030-
"p1": "The final version of this assessment is now available. All your answered questions, along with assessment information and demographics, will be transferred. Please note that this process is irreversible."
1030+
"p1": "The final version of this assessment is now available. Questions present in both the draft and final versions will be transferred, along with their observations, attached documents, feedback, and comments. Additionally, all demographic information and contacts will be transferred. The original draft version will remain accessible, and this upgrade will generate a new assessment."
10311031
},
10321032
"modules": {
10331033
"cpg": {

CSETWebNg/src/assets/i18n/es.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@
890890
"upgrade": "Actualizar",
891891
"final": "a la versión final",
892892
"convert": "Convirtiendo su evaluación, esto puede tardar unos momentos.",
893-
"p1": "La versión final de esta evaluación ya está disponible. Todas sus preguntas respondidas, junto con la información de la evaluación y la demografía, serán transferidas. Tenga en cuenta que este proceso es irreversible."
893+
"p1": "La versión final de esta evaluación ya está disponible. Las preguntas presentes tanto en la versión preliminar como en la versión final se transferirán, junto con sus observaciones, documentos adjuntos, comentarios y retroalimentación. Además, se transferirá toda la información demográfica y los contactos. La versión preliminar original seguirá siendo accesible y esta actualización generará una nueva evaluación."
894894
},
895895
"modules": {
896896
"cpg": {

CSETWebNg/src/assets/i18n/jp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,6 @@
482482
"upgrade": "アップグレード",
483483
"final": "最終バージョンへ",
484484
"convert": "評価を変換しています。しばらくお待ちください。",
485-
"p1": "この評価の最終バージョンが利用可能になりました。回答したすべての質問、評価情報、および人口統計が転送されます。このプロセスは元に戻せないことに注意してください"
485+
"p1": "この評価の最終版が利用可能になりました。下書き版と最終版の両方に含まれる質問は、観察、添付文書、フィードバック、およびコメントとともに転送されます。さらに、すべての人口統計情報と連絡先も転送されます。元の下書きバージョンは引き続きアクセス可能で、このアップグレードにより新しい評価が生成されます"
486486
}
487487
}

CSETWebNg/src/assets/i18n/uk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@
819819
"upgrade": "Оновити",
820820
"final": "до фінальної версії",
821821
"convert": "Конвертування вашої оцінки, це може зайняти кілька хвилин.",
822-
"p1": "Фінальна версія цієї оцінки тепер доступна. Всі ваші відповіді на питання, разом з інформацією про оцінку та демографічні дані, будуть передані. Зверніть увагу, що цей процес є незворотним."
822+
"p1": "Остаточна версія цієї оцінки вже доступна. Питання, що присутні як у чернетці, так і в остаточній версії, будуть перенесені разом із їхніми спостереженнями, прикріпленими документами, відгуками та коментарями. Крім того, буде перенесена вся демографічна інформація та контакти. Оригінальна чернетка залишатиметься доступною, і це оновлення створить нову оцінку."
823823
},
824824
"modules": {
825825
"cpg": {

0 commit comments

Comments
 (0)