Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Transfer date fixes #612

Merged
merged 3 commits into from
Sep 25, 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using Dfe.PrepareTransfers.Data.Models;
using Dfe.PrepareTransfers.Data.Models.Projects;
Expand Down Expand Up @@ -132,8 +133,8 @@ public void GivenHasDateIsNull_ShouldSetHasDate()
{
Dates = new TransferDates
{
Htb = "Date1",
Target = "Date2",
Htb = "10/10/2023",
Target = "10/10/2024",
HasHtbDate = null,
HasTargetDateForTransfer = null,
},
Expand All @@ -142,8 +143,8 @@ public void GivenHasDateIsNull_ShouldSetHasDate()
var result = subject.Map(toMap);
Assert.Null(result.Dates.HasHtbDate);
Assert.Null(result.Dates.HasTargetDateForTransfer);
Assert.Equal(result.Dates.HtbDate, toMap.Dates.Htb);
Assert.Equal(result.Dates.TargetDateForTransfer, toMap.Dates.Target);
Assert.Equal(DateTime.Parse(toMap.Dates.Htb).ToString("u"), result.Dates.HtbDate);
Assert.Equal(DateTime.Parse(toMap.Dates.Target).ToString("u"), result.Dates.TargetDateForTransfer);
}

private static void AssertGeneralInformationIsCorrect(Project toMap, TramsProjectUpdate result)
Expand All @@ -169,8 +170,8 @@ private static void AssertFeaturesAreCorrect(Project toMap, TramsProjectUpdate r

private static void AssertDatesAreCorrect(Project toMap, TramsProjectUpdate result)
{
Assert.Equal(toMap.Dates.Htb, result.Dates.HtbDate);
Assert.Equal(toMap.Dates.Target, result.Dates.TargetDateForTransfer);
Assert.Equal(DateTime.Parse(toMap.Dates.Htb).ToString("u"), result.Dates.HtbDate);
Assert.Equal(DateTime.Parse(toMap.Dates.Target).ToString("u"), result.Dates.TargetDateForTransfer);
Assert.True(result.Dates.HasHtbDate);
Assert.True(result.Dates.HasTargetDateForTransfer);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dfe.PrepareTransfers.Data.Models;
Expand Down Expand Up @@ -74,9 +75,9 @@ public static AcademyTransferProjectDates Dates(Project input)
{
return new AcademyTransferProjectDates
{
HtbDate = input.Dates.HasHtbDate != false ? input.Dates.Htb : null,
HtbDate = input.Dates.HasHtbDate != false && input.Dates.Htb != null ? DateTime.Parse(input.Dates.Htb).ToString("u") : null,
HasHtbDate = input.Dates.HasHtbDate,
TargetDateForTransfer = input.Dates.HasTargetDateForTransfer != false ? input.Dates.Target : null,
TargetDateForTransfer = input.Dates.HasTargetDateForTransfer != false && input.Dates.Target != null ? DateTime.Parse(input.Dates.Target).ToString("u") : null,
HasTargetDateForTransfer = input.Dates.HasTargetDateForTransfer
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async void GivenUrnAndAdvisoryBoardDate_UpdatesTheProject()

ProjectRepository.Verify(r =>
r.UpdateDates(It.Is<Data.Models.Project>(project =>
project.Dates.Htb == _subject.AdvisoryBoardViewModel.AdvisoryBoardDate.DateInputAsUniversalDateTimeString()
project.Dates.Htb == _subject.AdvisoryBoardViewModel.AdvisoryBoardDate.DateInputAsString()
&& project.Dates.HasHtbDate ==
!_subject.AdvisoryBoardViewModel.AdvisoryBoardDate.UnknownDate)),
Times.Once);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public async Task GivenUrnAndTargetDate_UpdatesTheProject()

ProjectRepository.Verify(r =>
r.UpdateDates(It.Is<Data.Models.Project>(project =>
project.Dates.Target == _subject.TargetDateViewModel.TargetDate.DateInputAsUniversalDateTimeString()
project.Dates.Target == _subject.TargetDateViewModel.TargetDate.DateInputAsString()
&& project.Dates.HasTargetDateForTransfer ==
!_subject.TargetDateViewModel.TargetDate.UnknownDate)),
Times.Once);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,7 @@ public async Task<IActionResult> OnPostAsync()
return Page();
}

if (AdvisoryBoardViewModel.AdvisoryBoardDate.UnknownDate)
{
projectResult.Dates.Htb = null;
}
else
{
projectResult.Dates.Htb = AdvisoryBoardViewModel.AdvisoryBoardDate.DateInputAsUniversalDateTimeString();
}
projectResult.Dates.Htb = AdvisoryBoardViewModel.AdvisoryBoardDate.DateInputAsString();
projectResult.Dates.HasHtbDate = !AdvisoryBoardViewModel.AdvisoryBoardDate.UnknownDate;

await _projectsRepository.UpdateDates(projectResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,7 @@ public async Task<IActionResult> OnPostAsync()
return Page();
}

if (TargetDateViewModel.TargetDate.UnknownDate)
{
projectResult.Dates.Target = null;
}
else
{
projectResult.Dates.Target = TargetDateViewModel.TargetDate.DateInputAsUniversalDateTimeString();
}
projectResult.Dates.Target = TargetDateViewModel.TargetDate.DateInputAsString();

projectResult.Dates.HasTargetDateForTransfer = !TargetDateViewModel.TargetDate.UnknownDate;

Expand Down