Пример #1
0
        public static string GetDisplayText(WageType type, WageUnit unit, WageDetails details)
        {
            WageDetails wageDetails = details ?? new WageDetails();

            switch (type)
            {
            case WageType.Custom:
                return(FormatWageAmount(wageDetails.Amount));

            case WageType.ApprenticeshipMinimum:

                if (!wageDetails.HoursPerWeek.HasValue || wageDetails.HoursPerWeek.Value == 0)
                {
                    return($"£{WageConstants.UnknownText}");
                }

                if (unit == WageUnit.Annually)
                {
                    return(GetYearlyApprenticeshipMinimumWage(wageDetails.HoursPerWeek.Value, wageDetails.StartDate));
                }

                return(GetWeeklyApprenticeshipMinimumWage(wageDetails.HoursPerWeek.Value, wageDetails.StartDate));

            case WageType.NationalMinimum:
                if (!wageDetails.HoursPerWeek.HasValue || wageDetails.HoursPerWeek.Value == 0)
                {
                    return($"£{WageConstants.UnknownText}");
                }

                if (unit == WageUnit.Annually)
                {
                    return(GetYearlyNationalMinimumWage(wageDetails.HoursPerWeek.Value, wageDetails.StartDate));
                }

                return(GetWeeklyNationalMinimumWage(wageDetails.HoursPerWeek.Value, wageDetails.StartDate));

            case WageType.Text:

                //if it's unknown, return standard unknown text
                string displayText = wageDetails.Text ?? $"£{WageConstants.UnknownText}";

                //if it's not unknown, then prepend a '£' sign to its decimal value.
                decimal wageDecimal;

                //if it's already got a '£' sign, or is text, fail to parse and all is good => return value.
                if (decimal.TryParse(displayText, out wageDecimal))
                {
                    displayText = FormatWageAmount(wageDecimal);
                }

                return(displayText);

            case WageType.CustomRange:
                return
                    ($"{FormatWageAmount(wageDetails.LowerBound)} - {FormatWageAmount(wageDetails.UpperBound)}");

            case WageType.CompetitiveSalary:
                return(WageConstants.CompetitiveSalaryText);

            case WageType.ToBeAgreedUponAppointment:
                return(WageConstants.ToBeAGreedUponAppointmentText);

            case WageType.Unwaged:
                return(WageConstants.UnwagedText);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type,
                                                      $"Invalid Wage Type: {type}");
            }
        }
Пример #2
0
        public static string GetDisplayTextFrequencyPostfix(WageType type, WageUnit unit, WageDetails wageDetails)
        {
            string postfix = unit.GetWagePostfix();

            string displayAmount = GetDisplayText(type, unit, wageDetails);

            if (string.IsNullOrWhiteSpace(displayAmount))
            {
                return(postfix);
            }

            return($"{displayAmount} {postfix}");
        }