Skip to content

Commit

Permalink
Merge pull request #3563 from cisagov/bug/acet684
Browse files Browse the repository at this point in the history
fixed a missed ACET refactor endpoint
  • Loading branch information
Marcus-Goectau authored Oct 4, 2023
2 parents 28ffb64 + bda2dc3 commit 5061ed4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
//
////////////////////////////////
using CSETWebCore.Business.Maturity;
using CSETWebCore.DataLayer.Model;
using CSETWebCore.Interfaces;
using CSETWebCore.Interfaces.Assessment;
Expand All @@ -18,18 +19,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static Lucene.Net.Util.Fst.Util;

namespace CSETWebCore.Business.Assessment
{
public class ACETAssessmentBusiness : AssessmentBusiness, ICreateAssessmentBusiness, IACETAssessmentBusiness
{
private CSETContext _context;
private IMaturityBusiness _maturityBusiness;

public ACETAssessmentBusiness(IHttpContextAccessor httpContext, ITokenManager authentication, IUtilities utilities, IContactBusiness contactBusiness, ISalBusiness salBusiness, IMaturityBusiness maturityBusiness, IAssessmentUtil assessmentUtil, IStandardsBusiness standardsBusiness, IDiagramManager diagramManager, CSETContext context)
: base(httpContext, authentication, utilities, contactBusiness, salBusiness, maturityBusiness, assessmentUtil, standardsBusiness, diagramManager, context)
{

this._context = context;
this._maturityBusiness = maturityBusiness;
}

public new int SaveAssessmentDetail(int assessmentId, AssessmentDetail assessment)
Expand All @@ -42,16 +46,40 @@ public ACETAssessmentBusiness(IHttpContextAccessor httpContext, ITokenManager au
dbAssessment.ISE_StateLed = assessment.ISE_StateLed;
dbAssessment.MatDetail_targetBandOnly = true;


if (!assessment.AssessmentName.StartsWith("ISE ") && (!assessment.AssessmentName.StartsWith("Merged ")))
var model = _maturityBusiness.GetMaturityModel(assessmentId);
if (model != null)
{
var creditUnion = string.IsNullOrEmpty(assessment.CreditUnion)
? string.Empty
: assessment.CreditUnion + " ";
assessment.AssessmentName = "ACET " + dbAssessment.Charter + " " + creditUnion + dbAssessment.Assessment_Date.ToString("MMddyy");
// if ACET (1), name "ACET "
if (model.ModelId == 1 && (!assessment.AssessmentName.StartsWith("Merged ")))
{
var creditUnion = string.IsNullOrEmpty(assessment.CreditUnion)
? string.Empty
: assessment.CreditUnion + " ";
assessment.AssessmentName = "ACET " + dbAssessment.Charter + " " + creditUnion + dbAssessment.Assessment_Date.ToString("MMddyy");
}
}

var result = _context.INFORMATION.Where(x => x.Id == assessmentId).FirstOrDefault();

if (result != null)
{
// set workflow for legacy assessments
if (string.IsNullOrEmpty(assessment.Workflow))
{
if (result.IsAcetOnly ?? false)
{
assessment.Workflow = "ACET";
}
else
{
assessment.Workflow = "BASE";
}
}
}

var dbInformation = _context.INFORMATION.Where(x => x.Id == assessmentId).FirstOrDefault();
dbInformation.Assessment_Name = assessment.AssessmentName;
dbInformation.Workflow = assessment.Workflow;
_context.INFORMATION.Update(dbInformation);
_context.SaveChanges();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
//
//
////////////////////////////////
using CSETWebCore.DataLayer.Model;
using CSETWebCore.Model.Assessment;

namespace CSETWebCore.Interfaces.Assessment
{
public interface IACETAssessmentBusiness
{
int SaveAssessmentDetail(int assessmentId, AssessmentDetail assessmentDetail);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ public IActionResult Post([FromBody] AssessmentDetail assessmentDetail)
throw new Exception("Not currently authorized to update the Assessment", null);
}

if (assessmentDetail.Workflow == "ACET")
{
return Ok(_acsetAssessmentBusiness.SaveAssessmentDetail(assessmentId, assessmentDetail));
}

return Ok(_assessmentBusiness.SaveAssessmentDetail(assessmentId, assessmentDetail));
}

Expand Down

0 comments on commit 5061ed4

Please sign in to comment.