Skip to content

Commit

Permalink
Merge pull request #850 from cabinetoffice/feature/dp-739-pdf-categor…
Browse files Browse the repository at this point in the history
…y-connected-person-data-added

Feature/dp 739 pdf category connected person data added
  • Loading branch information
JBaigGoaco authored Oct 28, 2024
2 parents 4830fc1 + b0f670a commit e4f6c07
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using CO.CDP.Organisation.WebApiClient;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using CO.CDP.OrganisationApp.Models;
using CO.CDP.OrganisationApp.Constants;
using CO.CDP.OrganisationApp.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;

namespace CO.CDP.OrganisationApp.Pages.Users;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ public static BasicInformation CreateMockBasicInformation()
RegisteredLegalForm = "Private Limited",
LawRegistered = "UK",
RegistrationDate = DateTimeOffset.UtcNow.AddYears(-10)
}
},
OrganisationName = "Organisation Name"
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,29 @@ public async Task Execute_WhenDoesNotHaveAccessToOrganisation_ThrowsUserUnauthor

await act.Should().ThrowAsync<UserUnauthorizedException>();
}

[Fact]
public async Task DataService_ShouldReturnBasicInformationWithOrganisationName()
{
var organisationId = Guid.NewGuid();
var sharecode = "valid-sharecode";
var expectedOrganisationName = "Organisation Name";

var sharedSupplierInformation = new SharedSupplierInformation
{
OrganisationId = organisationId,
BasicInformation = DataSharingFactory.CreateMockBasicInformation(),
ConnectedPersonInformation = DataSharingFactory.CreateMockConnectedPersonInformation(),
FormAnswerSetForPdfs = DataSharingFactory.CreateMockFormAnswerSetForPdfs(),
AttachedDocuments = []
};

_dataService.Setup(service => service.GetSharedSupplierInformationAsync(sharecode))
.ReturnsAsync(sharedSupplierInformation);

var result = await _dataService.Object.GetSharedSupplierInformationAsync(sharecode);

result.Should().NotBeNull();
result.BasicInformation.OrganisationName.Should().Be(expectedOrganisationName);
}
}
13 changes: 6 additions & 7 deletions Services/CO.CDP.DataSharing.WebApi/DataService/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public IEnumerable<FormAnswerSetForPdf> MapFormAnswerSetsForPdf(
case FormQuestionType.YesOrNo:
{
pdfAnswerSet.QuestionAnswers.Add(new Tuple<string, string>($"{answer.Question.Title}",
answer.OptionValue ?? "No"));
answer.OptionValue ?? "Not specified"));
break;
}
case FormQuestionType.Date:
Expand All @@ -66,20 +66,20 @@ public IEnumerable<FormAnswerSetForPdf> MapFormAnswerSetsForPdf(
case FormQuestionType.Url:
{
pdfAnswerSet.QuestionAnswers.Add(new Tuple<string, string>($"{answer.Question.Title}",
answer.TextValue ?? ""));
answer.TextValue ?? "Not specified"));
break;
}
case FormQuestionType.FileUpload:
{
pdfAnswerSet.QuestionAnswers.Add(new Tuple<string, string>($"{answer.Question.Title}",
answer.TextValue ?? "No"));
answer.TextValue ?? "Not specified"));
break;
}
case FormQuestionType.Text:
case FormQuestionType.MultiLine:
{
pdfAnswerSet.QuestionAnswers.Add(new Tuple<string, string>($"{answer.Question.Title}:",
answer.TextValue ?? ""));
answer.TextValue ?? "Not specified"));
break;
}
}
Expand All @@ -102,7 +102,6 @@ public static BasicInformation MapToBasicInformation(Organisation organisation)
{
StreetAddress = a.Address.StreetAddress,
Locality = a.Address.Locality,
Region = a.Address.Region,
PostalCode = a.Address.PostalCode,
CountryName = a.Address.CountryName,
Country = a.Address.Country,
Expand All @@ -118,7 +117,6 @@ public static BasicInformation MapToBasicInformation(Organisation organisation)
{
StreetAddress = a.Address.StreetAddress,
Locality = a.Address.Locality,
Region = a.Address.Region,
PostalCode = a.Address.PostalCode,
CountryName = a.Address.CountryName,
Country = a.Address.Country,
Expand Down Expand Up @@ -162,7 +160,8 @@ public static BasicInformation MapToBasicInformation(Organisation organisation)
WebsiteAddress = websiteAddress,
EmailAddress = emailAddress,
OrganisationType = organisationType,
LegalForm = legalForm
LegalForm = legalForm,
OrganisationName = organisation.Name
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public record BasicInformation
public string? EmailAddress { get; init; }
public OrganisationType OrganisationType { get; init; }
public BasicLegalForm? LegalForm { get; init; }
public string? OrganisationName { get; init; }
}

public record BasicLegalForm
Expand Down
Loading

0 comments on commit e4f6c07

Please sign in to comment.