41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
namespace TaxBaik.Application.Services;
|
|
|
|
using TaxBaik.Application.Seasonal;
|
|
|
|
public class SeasonalMarketingService
|
|
{
|
|
public CurrentSeasonDto? GetCurrentSeason()
|
|
{
|
|
var today = DateTime.Today;
|
|
|
|
foreach (var season in TaxSeasonCalendar.Seasons)
|
|
{
|
|
var start = new DateTime(today.Year, season.StartMonth, season.StartDay);
|
|
var end = new DateTime(today.Year, season.EndMonth, season.EndDay);
|
|
|
|
if (today >= start && today <= end)
|
|
{
|
|
var effectiveEnd = BusinessDayCalculator.GetEffectiveBusinessDate(DateOnly.FromDateTime(end)).ToDateTime(TimeOnly.MinValue);
|
|
var days = BusinessDayCalculator.GetBusinessDayDiff(DateOnly.FromDateTime(end), DateOnly.FromDateTime(today));
|
|
return new CurrentSeasonDto
|
|
{
|
|
Key = season.Key,
|
|
Name = season.Name,
|
|
HeroHeadline = season.HeroHeadline,
|
|
HeroSubtext = season.HeroSubtext,
|
|
UrgencyBadge = season.UrgencyBadge.Replace("{n}", days.ToString()),
|
|
FocusService = season.FocusService,
|
|
RelatedCategorySlug = season.RelatedCategorySlug,
|
|
CtaText = season.CtaText,
|
|
DaysUntilDeadline = days,
|
|
Deadline = effectiveEnd
|
|
};
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public IReadOnlyList<TaxSeason> GetFullCalendar() => TaxSeasonCalendar.Seasons;
|
|
}
|