47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using Microsoft.EntityFrameworkCore;
|
||
using PARR.DAL.Models;
|
||
using PARR.DAL.Services.Interfaces;
|
||
|
||
namespace PARR.TemplateDistributor
|
||
{
|
||
internal class TemplateDistributor : ITemplateDistributor
|
||
{
|
||
private readonly IApplicationsInWorkService applicationsInWorkService;
|
||
|
||
public TemplateDistributor(IApplicationsInWorkService applicationsInWorkService)
|
||
{
|
||
this.applicationsInWorkService = applicationsInWorkService;
|
||
}
|
||
|
||
|
||
public async Task UpdateScheduleAsync(Guid applicationInWorkId)
|
||
{
|
||
// все шаблоны по applicationInWorkId
|
||
// группирует по РР
|
||
// -> DistributeTemplateForPeriodAsync
|
||
// сохранить в БД
|
||
}
|
||
|
||
|
||
|
||
public async Task<List<Template>> DistributeTemplateAsync(List<Template> templates, Guid applicationInWorkId)
|
||
{
|
||
//TODO: ЗАГУЛШКА переделать!
|
||
|
||
// распределить?
|
||
// не распределить, NextRun = appInWork.ReferenceDate
|
||
|
||
var appInWork = await applicationsInWorkService.Get().FirstOrDefaultAsync(t => t.Id == applicationInWorkId);
|
||
if (appInWork == null)
|
||
{
|
||
throw new Exception("ERROROORORO!!!");
|
||
}
|
||
|
||
|
||
templates.ForEach(t => t.NextRun = appInWork.ReferenceDate);
|
||
|
||
return templates;
|
||
}
|
||
}
|
||
}
|