40 lines
1.2 KiB
C#
40 lines
1.2 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;
|
|
}
|
|
|
|
|
|
//TODO: AppInWorkId - перераспределение, очередь
|
|
//public async Task
|
|
// распределить?
|
|
// не распределить, NextRun = appInWork.ReferenceDate
|
|
|
|
|
|
public async Task<List<Template>> DistributeTemplateForPeriodAsync(List<Template> templates, Guid applicationInWorkId)
|
|
{
|
|
//TODO: ЗАГУЛШКА переделать!
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|