feat(dal, templateDistributor): шаблон для templateDistributor
This commit is contained in:
39
PARR.TemplateDistributor/TemplateDistributor.cs
Normal file
39
PARR.TemplateDistributor/TemplateDistributor.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user