Files
parr_api/PARR.TemplateDistributor/TemplateDistributor.cs

47 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}
}