<commit_before>﻿@using SFA.DAS.Commitments.Api.Types.Apprenticeship
@using SFA.DAS.EAS.Web.Extensions
@using SFA.DAS.EAS.Web.ViewModels.ManageApprenticeships

@model UpdateApprenticeshipViewModel

@{
    var currentValuHeader = string .IsNullOrEmpty(Model.CurrentTableHeadingText) ? "Current" :  Model.CurrentTableHeadingText;
}

<table class="edited-changes">
    <thead>
    <tr>
        <th></th>
        <th scope="col">@currentValuHeader</th>
        <th scope="col">Changed to</th>
    </tr>
    </thead>
    <tbody>
    @if (!string.IsNullOrWhiteSpace(Model.FirstName) || !string.IsNullOrWhiteSpace(Model.LastName))
    {
        <tr>
            <th scope="row">Name</th>
            <td>@Model.OriginalApprenticeship.FirstName @Model.OriginalApprenticeship.LastName</td>
            <td class="changed-item">@GetNameChange(Model.OriginalApprenticeship, Model)</td>
            @Html.Hidden("FirstName", Model.FirstName)
            @Html.Hidden("Lastname", Model.LastName)
        </tr>
    }

    @if (Model.DateOfBirth?.DateTime != null)
    {
        <tr>
            <th scope="row">Date of birth</th>
            <td>
                @if (Model.OriginalApprenticeship.DateOfBirth.HasValue)
                {
                    @Model.OriginalApprenticeship.DateOfBirth.Value.ToGdsFormat()
                }
            </td>
            <td class="changed-item">@Model.DateOfBirth.DateTime.Value.ToGdsFormat()</td>
            @Html.Hidden("DateOfBirth.Day", Model.DateOfBirth.Day)
            @Html.Hidden("DateOfBirth.Month", Model.DateOfBirth.Month)
            @Html.Hidden("DateOfBirth.Year", Model.DateOfBirth.Year)
        </tr>
    }

    @if (Model.TrainingName != null)
    {
        <tr>
            <th scope="row">Apprenticeship training course</th>
            <td>@Model.OriginalApprenticeship.TrainingName </td>
            <td class="changed-item">@Model.TrainingName</td>
            @Html.Hidden("TrainingCode", Model.TrainingCode)
        </tr>
    }

    @if (Model.StartDate?.DateTime != null)
    {
        <tr>
            <th scope="row">Planned training start date</th>
            <td>@Model.OriginalApprenticeship.StartDate.Value.ToGdsFormat() </td>
            <td class="changed-item">@Model.StartDate.DateTime.Value.ToGdsFormat()</td>
            @Html.Hidden("StartDate.Month", Model.StartDate.Month)
            @Html.Hidden("StartDate.Year", Model.StartDate.Year)
        </tr>
    }

    @if (Model.EndDate?.DateTime != null)
    {
        <tr>
            <th scope="row">Planned training end date</th>
            <td>@Model.OriginalApprenticeship.EndDate.Value.ToGdsFormat() </td>
            <td class="changed-item">@Model.EndDate.DateTime.Value.ToGdsFormat()</td>
            @Html.Hidden("EndDate.Month", Model.EndDate.Month)
            @Html.Hidden("EndDate.Year", Model.EndDate.Year)
        </tr>
    }

    @if (!string.IsNullOrEmpty(Model.Cost))
    {
        <tr>
            <th scope="row">Cost</th>
            <td>@Model.OriginalApprenticeship.Cost.FormatCost() </td>
            <td class="changed-item">@FormatCost(Model.Cost)</td>
            @Html.Hidden("Cost", Model.Cost)
        </tr>
    }

    @if (Model.EmployerRef != null)
    {
        <tr>
            <th scope="row">Reference</th>
            <td>@Model.OriginalApprenticeship.EmployerReference</td>
            <td class="changed-item">@Model.EmployerRef</td>
            @Html.Hidden("EmployerRef", Model.EmployerRef)
        </tr>
    }
    </tbody>
</table>

@functions
{
    private static string GetNameChange(ApprenticeshipDetailsViewModel originalApprenticeship, UpdateApprenticeshipViewModel update)
    {
        var first = !string.IsNullOrWhiteSpace(update.FirstName) ? update.FirstName : originalApprenticeship.FirstName;
        var last = !string.IsNullOrWhiteSpace(update.LastName) ? update.LastName : originalApprenticeship.LastName;
        return $"{first} {last}";
    }

    public string FormatCost(string cost)
    {
        if (!string.IsNullOrEmpty(cost))
        {
            var dCost = decimal.Parse(cost);
            return $"£{dCost:n0}";
        }
        return string.Empty;
    }
}<commit_msg>Adds missing training name and type fields in markup (#754)<commit_after>﻿@using SFA.DAS.Commitments.Api.Types.Apprenticeship
@using SFA.DAS.EAS.Web.Extensions
@using SFA.DAS.EAS.Web.ViewModels.ManageApprenticeships

@model UpdateApprenticeshipViewModel

@{
    var currentValuHeader = string .IsNullOrEmpty(Model.CurrentTableHeadingText) ? "Current" :  Model.CurrentTableHeadingText;
}

<table class="edited-changes">
    <thead>
    <tr>
        <th></th>
        <th scope="col">@currentValuHeader</th>
        <th scope="col">Changed to</th>
    </tr>
    </thead>
    <tbody>
    @if (!string.IsNullOrWhiteSpace(Model.FirstName) || !string.IsNullOrWhiteSpace(Model.LastName))
    {
        <tr>
            <th scope="row">Name</th>
            <td>@Model.OriginalApprenticeship.FirstName @Model.OriginalApprenticeship.LastName</td>
            <td class="changed-item">@GetNameChange(Model.OriginalApprenticeship, Model)</td>
            @Html.Hidden("FirstName", Model.FirstName)
            @Html.Hidden("Lastname", Model.LastName)
        </tr>
    }

    @if (Model.DateOfBirth?.DateTime != null)
    {
        <tr>
            <th scope="row">Date of birth</th>
            <td>
                @if (Model.OriginalApprenticeship.DateOfBirth.HasValue)
                {
                    @Model.OriginalApprenticeship.DateOfBirth.Value.ToGdsFormat()
                }
            </td>
            <td class="changed-item">@Model.DateOfBirth.DateTime.Value.ToGdsFormat()</td>
            @Html.Hidden("DateOfBirth.Day", Model.DateOfBirth.Day)
            @Html.Hidden("DateOfBirth.Month", Model.DateOfBirth.Month)
            @Html.Hidden("DateOfBirth.Year", Model.DateOfBirth.Year)
        </tr>
    }

    @if (Model.TrainingName != null)
    {
        <tr>
            <th scope="row">Apprenticeship training course</th>
            <td>@Model.OriginalApprenticeship.TrainingName </td>
            <td class="changed-item">@Model.TrainingName</td>
            @Html.Hidden("TrainingCode", Model.TrainingCode)
            @Html.Hidden("TrainingName", Model.TrainingName)
            @Html.Hidden("TrainingType", Model.TrainingType)
        </tr>
    }

    @if (Model.StartDate?.DateTime != null)
    {
        <tr>
            <th scope="row">Planned training start date</th>
            <td>@Model.OriginalApprenticeship.StartDate.Value.ToGdsFormat() </td>
            <td class="changed-item">@Model.StartDate.DateTime.Value.ToGdsFormat()</td>
            @Html.Hidden("StartDate.Month", Model.StartDate.Month)
            @Html.Hidden("StartDate.Year", Model.StartDate.Year)
        </tr>
    }

    @if (Model.EndDate?.DateTime != null)
    {
        <tr>
            <th scope="row">Planned training end date</th>
            <td>@Model.OriginalApprenticeship.EndDate.Value.ToGdsFormat() </td>
            <td class="changed-item">@Model.EndDate.DateTime.Value.ToGdsFormat()</td>
            @Html.Hidden("EndDate.Month", Model.EndDate.Month)
            @Html.Hidden("EndDate.Year", Model.EndDate.Year)
        </tr>
    }

    @if (!string.IsNullOrEmpty(Model.Cost))
    {
        <tr>
            <th scope="row">Cost</th>
            <td>@Model.OriginalApprenticeship.Cost.FormatCost() </td>
            <td class="changed-item">@FormatCost(Model.Cost)</td>
            @Html.Hidden("Cost", Model.Cost)
        </tr>
    }

    @if (Model.EmployerRef != null)
    {
        <tr>
            <th scope="row">Reference</th>
            <td>@Model.OriginalApprenticeship.EmployerReference</td>
            <td class="changed-item">@Model.EmployerRef</td>
            @Html.Hidden("EmployerRef", Model.EmployerRef)
        </tr>
    }
    </tbody>
</table>

@functions
{
    private static string GetNameChange(ApprenticeshipDetailsViewModel originalApprenticeship, UpdateApprenticeshipViewModel update)
    {
        var first = !string.IsNullOrWhiteSpace(update.FirstName) ? update.FirstName : originalApprenticeship.FirstName;
        var last = !string.IsNullOrWhiteSpace(update.LastName) ? update.LastName : originalApprenticeship.LastName;
        return $"{first} {last}";
    }

    public string FormatCost(string cost)
    {
        if (!string.IsNullOrEmpty(cost))
        {
            var dCost = decimal.Parse(cost);
            return $"£{dCost:n0}";
        }
        return string.Empty;
    }
}
{'fraction_non_alphanumeric': 0.1434792843691149, 'fraction_numerical': 0.0005885122410546139, 'mean_word_length': 2.417940466613033, 'pattern_counts': {'":': 0, '<': 143, '<?xml version=': 0, '>': 143, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2402268', 'n_tokens_mistral': 2707, 'n_tokens_neox': 2662, 'n_words': 365}