From 9a19f317fac2f9ec980349e8161514de00209642 Mon Sep 17 00:00:00 2001 From: Natalie Hergesheimer Date: Mon, 30 Sep 2024 13:07:53 -0600 Subject: [PATCH 1/3] Assessment editor/creator logic complete --- .../Assessment/AssessmentBusiness.cs | 11 ++++++++++ .../Assessment/IAssessmentBusiness.cs | 2 ++ .../Controllers/AssessmentController.cs | 20 +++++++++++++++++++ .../contact-item/contact-item.component.html | 14 ++++++++++--- .../contact-item/contact-item.component.ts | 12 ++++++++++- .../src/app/services/assessment.service.ts | 12 +++++++++++ 6 files changed, 67 insertions(+), 4 deletions(-) diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Assessment/AssessmentBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Assessment/AssessmentBusiness.cs index 8a9d7df746..ca3a829832 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Assessment/AssessmentBusiness.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Assessment/AssessmentBusiness.cs @@ -961,6 +961,17 @@ public string GetOtherRemarks(int assessmentId) return ""; } + /// + /// Gets the userID that created the current assessment + /// + /// userID + public int? GetAssessmentCreator(int assessmentId) + { + var assessment = _context.ASSESSMENTS.FirstOrDefault(x => x.Assessment_Id == assessmentId); + return assessment?.AssessmentCreatorId; + } + + /// /// Persists OTHER-REMARKS. diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Interfaces/Assessment/IAssessmentBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Interfaces/Assessment/IAssessmentBusiness.cs index 3ff3b9eccb..a04c6c49e5 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Interfaces/Assessment/IAssessmentBusiness.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Interfaces/Assessment/IAssessmentBusiness.cs @@ -38,6 +38,8 @@ public interface IAssessmentBusiness IList GetNames(int id1, int id2, int? id3, int? id4, int? id5, int? id6, int? id7, int? id8, int? id9, int? id10); string GetOtherRemarks(int assessmentId); + + int? GetAssessmentCreator(int assessmentId); void SaveOtherRemarks(int assessmentId, string remark); void clearFirstTime(int userid, int assessmentId); diff --git a/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/AssessmentController.cs b/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/AssessmentController.cs index e29f83156a..a03088aa78 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/AssessmentController.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/AssessmentController.cs @@ -488,5 +488,25 @@ public IActionResult GetAssessmentDocuments([FromQuery] int id1, [FromQuery] int return Ok(this._assessmentBusiness.GetAssessmentDocuments(id1, id2, id3, id4, id5, id6, id7, id8, id9, id10)); } + + [HttpGet] + [Route("api/assessmentCreator")] + public IActionResult AssessmentCreator() + { + try + { + int assessmentId = _tokenManager.AssessmentForUser(); + int? userId = _tokenManager.GetCurrentUserId(); + var creatorId = this._assessmentBusiness.GetAssessmentCreator((assessmentId)); + + return Ok(creatorId); + } + catch (Exception exc) + { + NLog.LogManager.GetCurrentClassLogger().Error($"... {exc}"); + } + + return null; + } } } diff --git a/CSETWebNg/src/app/assessment/prepare/assessment-info/assessment-contacts/contact-item/contact-item.component.html b/CSETWebNg/src/app/assessment/prepare/assessment-info/assessment-contacts/contact-item/contact-item.component.html index 045b82be86..3abcaf7a28 100644 --- a/CSETWebNg/src/app/assessment/prepare/assessment-info/assessment-contacts/contact-item/contact-item.component.html +++ b/CSETWebNg/src/app/assessment/prepare/assessment-info/assessment-contacts/contact-item/contact-item.component.html @@ -53,8 +53,8 @@ Participated
in Site Visit
- Primary
Point of Contact
+ + - +
    -
      Primary
      Point of Contact
    +
      Primary Point of Contact
      Assessment Creator
      Assessment Editor
    From e90f17c0f9d936d22c865c79d1f7fdcd41e8654d Mon Sep 17 00:00:00 2001 From: Natalie Hergesheimer Date: Tue, 1 Oct 2024 08:33:57 -0600 Subject: [PATCH 3/3] Remove unnecessary userID grab --- .../CSETWeb_ApiCore/Controllers/AssessmentController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/AssessmentController.cs b/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/AssessmentController.cs index a03088aa78..510ff36c54 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/AssessmentController.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWeb_ApiCore/Controllers/AssessmentController.cs @@ -496,7 +496,6 @@ public IActionResult AssessmentCreator() try { int assessmentId = _tokenManager.AssessmentForUser(); - int? userId = _tokenManager.GetCurrentUserId(); var creatorId = this._assessmentBusiness.GetAssessmentCreator((assessmentId)); return Ok(creatorId);