feat(bll): заготовка ICalendarService
This commit is contained in:
69
PARR.BLL/Services/Implementations/CalendarService.cs
Normal file
69
PARR.BLL/Services/Implementations/CalendarService.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
|
||||
namespace PARR.BLL.Services.Implementations
|
||||
{
|
||||
public delegate Task<List<DateOnly>> GetWeekendsDelegate(DateOnly start, DateOnly end);
|
||||
|
||||
|
||||
internal class CalendarService : ICalendarService
|
||||
{
|
||||
|
||||
private DateOnly GetEndPeriodDate(DateOnly startPeriod, TimeSpan distributionPeriod)
|
||||
{
|
||||
return startPeriod.AddDays(distributionPeriod.Days).AddDays(-1);
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<DateOnly>> GetWorkDatesForPeriodAsync(DateOnly startPeriod, TimeSpan distributionPeriod, GetWeekendsDelegate getWeekends)
|
||||
{
|
||||
var endPeriod = GetEndPeriodDate(startPeriod, distributionPeriod);
|
||||
|
||||
|
||||
var weekends = await getWeekends.Invoke(startPeriod, endPeriod);
|
||||
|
||||
//TODO: logic!!!
|
||||
|
||||
//временно сделаем список руками рабочих дней
|
||||
var workDates = new List<DateOnly>();
|
||||
|
||||
|
||||
return workDates;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Test
|
||||
{
|
||||
private readonly ICalendarService calendarService;
|
||||
|
||||
public Test(ICalendarService calendarService)
|
||||
{
|
||||
this.calendarService = calendarService;
|
||||
}
|
||||
|
||||
|
||||
public async void Ttt()
|
||||
{
|
||||
var tService = new TestService();
|
||||
// var endPeriod = calendarService.GetEndPeriodDate(new DateOnly(2024, 1, 1), TimeSpan.Parse("30:00:00:00"));
|
||||
|
||||
var workDays = await calendarService.GetWorkDatesForPeriodAsync(new DateOnly(2024, 1, 1), TimeSpan.Parse("30:00:00:00"), tService.GetWeekendsAsync);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class TestService
|
||||
{
|
||||
public async Task<List<DateOnly>> GetWeekendsAsync(DateOnly start, DateOnly end)
|
||||
{
|
||||
|
||||
await Task.Delay(1000);
|
||||
|
||||
return new List<DateOnly> { new DateOnly(2024, 1, 12) };
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user