diff --git a/Dfe.Academies.Academisation.Service/Commands/FormAMatProject/CreateFormAMatProjectsCommandHandler.cs b/Dfe.Academies.Academisation.Service/Commands/FormAMatProject/CreateFormAMatProjectsCommandHandler.cs index 8f35e7ee8..2a4ca9f01 100644 --- a/Dfe.Academies.Academisation.Service/Commands/FormAMatProject/CreateFormAMatProjectsCommandHandler.cs +++ b/Dfe.Academies.Academisation.Service/Commands/FormAMatProject/CreateFormAMatProjectsCommandHandler.cs @@ -41,19 +41,18 @@ public async Task Handle(CreateFormAMatProjectsCommand request, { // create formAMat formAMat = FormAMatProject.Create(conversionProject.Details.NameOfTrust, conversionProject.Details.ApplicationReferenceNumber, _dateTimeProvider.Now); - _formAMatProjectRepository.Insert(formAMat as FormAMatProject); + _formAMatProjectRepository.CreateFormAMatProjectWithTrustReferenceNumber(formAMat); await _formAMatProjectRepository.UnitOfWork.SaveChangesAsync(cancellationToken); } conversionProject.SetFormAMatProjectId(formAMat.Id); + conversionProject.SetIncomingTrust(formAMat.TrustReferenceNumber, conversionProject.Details.NameOfTrust); _conversionProjectRepository.Update(conversionProject as Domain.ProjectAggregate.Project); } - await _conversionProjectRepository.UnitOfWork.SaveChangesAsync(cancellationToken); - // returning 'CommandSuccessResult', client will have to retrieve the updated transfer project to refresh data return new CommandSuccessResult(); }