Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DueBefore to /active instances endpoint #179

Merged
merged 2 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Altinn.App.Api/Controllers/InstancesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,15 +698,15 @@ public async Task<ActionResult<List<SimpleInstance>>> GetActiveInstances([FromRo
if (lastChangedBy?.Length == 9)
{
Organization? organization = await _registerClient.ER.GetOrganization(lastChangedBy);
if(organization is not null && !string.IsNullOrEmpty(organization.Name))
if (organization is not null && !string.IsNullOrEmpty(organization.Name))
{
userAndOrgLookup.Add(lastChangedBy, organization.Name);
}
}
else if (int.TryParse(lastChangedBy, out int lastChangedByInt))
{
UserProfile? user = await _profileClientClient.GetUserProfile(lastChangedByInt);
if(user is not null && user.Party is not null && !string.IsNullOrEmpty(user.Party.Name))
if (user is not null && user.Party is not null && !string.IsNullOrEmpty(user.Party.Name))
{
userAndOrgLookup.Add(lastChangedBy, user.Party.Name);
}
Expand Down
1 change: 1 addition & 0 deletions src/Altinn.App.Api/Mappers/SimpleInstanceMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static SimpleInstance MapInstanceToSimpleInstance(Instance instance, stri
return new SimpleInstance
{
Id = instance.Id,
DueBefore = instance.DueBefore,
PresentationTexts = instance.PresentationTexts,
LastChanged = instance.LastChanged,
LastChangedBy = lastChangedByName
Expand Down
5 changes: 5 additions & 0 deletions src/Altinn.App.Api/Models/SimpleInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class SimpleInstance
/// </summary>
public Dictionary<string, string>? PresentationTexts { get; set; }

/// <summary>
/// Gets or sets the due date to submit the instance to application owner.
/// </summary>
public DateTime? DueBefore { get; set; }

/// <summary>
/// Last changed date time in UTC format.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public async Task UnknownUser_ReturnsEmptyString()
new()
{
Id = $"{1234}/{Guid.NewGuid()}",
DueBefore = DateTime.Today.AddDays(20),
LastChanged = DateTime.Now,
LastChangedBy = "12345",
PresentationTexts = new()
Expand All @@ -117,6 +118,7 @@ public async Task UnknownUser_ReturnsEmptyString()
var expected = instances.Select(i => new SimpleInstance()
{
Id = i.Id,
DueBefore = i.DueBefore,
PresentationTexts = i.PresentationTexts,
LastChanged = i.LastChanged,
LastChangedBy = i.LastChangedBy switch
Expand Down Expand Up @@ -169,6 +171,7 @@ public async Task UserProfilePartyIsNull_ReturnsEmptyString()
var expected = instances.Select(i => new SimpleInstance()
{
Id = i.Id,
DueBefore = i.DueBefore,
PresentationTexts = i.PresentationTexts,
LastChanged = i.LastChanged,
LastChangedBy = i.LastChangedBy switch
Expand Down Expand Up @@ -216,6 +219,7 @@ public async Task KnownUser_ReturnsUserName()
var expected = instances.Select(i => new SimpleInstance()
{
Id = i.Id,
DueBefore = i.DueBefore,
PresentationTexts = i.PresentationTexts,
LastChanged = i.LastChanged,
LastChangedBy = i.LastChangedBy switch
Expand Down Expand Up @@ -268,6 +272,7 @@ public async Task LastChangedBy9digits_LooksForOrg()
var expected = instances.Select(i => new SimpleInstance()
{
Id = i.Id,
DueBefore = i.DueBefore,
PresentationTexts = i.PresentationTexts,
LastChanged = i.LastChanged,
LastChangedBy = i.LastChangedBy switch
Expand Down Expand Up @@ -315,6 +320,7 @@ public async Task LastChangedBy9digits_FindsOrg()
var expected = instances.Select(i => new SimpleInstance()
{
Id = i.Id,
DueBefore = i.DueBefore,
PresentationTexts = i.PresentationTexts,
LastChanged = i.LastChanged,
LastChangedBy = i.LastChangedBy switch
Expand Down