-
Notifications
You must be signed in to change notification settings - Fork 0
/
Worker.cs
48 lines (40 loc) · 1.41 KB
/
Worker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using RiseFoodServiceWork.Services.LocalDatabase;
using RiseFoodServiceWork.Services.RemoteDatabase;
namespace RiseFoodServiceWork
{
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
private readonly ILocalDatabaseService _localDatabaseService;
private readonly IRemoteDatabaseService _remoteDatabaseService;
public Worker(ILogger<Worker> logger,
ILocalDatabaseService localDatabaseService,
IRemoteDatabaseService remoteDatabaseService)
{
_logger = logger;
_localDatabaseService = localDatabaseService;
_remoteDatabaseService = remoteDatabaseService;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
if (_remoteDatabaseService.IsCollectionExist())
{
_logger.LogInformation("jA EZXIXWSDASK AJ DAICJKA =SCOJA");
}
else
{
foreach (var supplie in await _localDatabaseService.GetAllSupplies())
{
await _remoteDatabaseService.SaveSupplie(supplie);
}
}
}
}
}