Skip to content

Commit

Permalink
Use service-based hangfire
Browse files Browse the repository at this point in the history
  • Loading branch information
Варнавский Владимир Николаевич committed Oct 31, 2023
1 parent 756c531 commit e05f39e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Anyor.Tests/AmoToSheetFunctionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Api.Common;
using Api.Controllers;
using Api.Services;
using Hangfire;
using Hangfire.MemoryStorage;
using Microsoft.AspNetCore.Http;

namespace Anyor.Tests;
Expand All @@ -24,7 +26,7 @@ public void Setup()
[Test]
public void AllFunctionTest()
{
var controller = new PreachyBudgetController();
var controller = new PreachyBudgetController(new BackgroundJobClient(new MemoryStorage()));
var s =
"leads%5Bstatus%5D%5B0%5D%5Bid%5D=10754147&leads%5Bstatus%5D%5B0%5D%5Bstatus_id%5D=54423922&leads%5Bstatus%5D%5B0%5D%5Bpipeline_id%5D=6344290&leads%5Bstatus%5D%5B0%5D%5Bold_status_id%5D=54435014&leads%5Bstatus%5D%5B0%5D%5Bold_pipeline_id%5D=6344290&account%5Bid%5D=30307558&account%5Bsubdomain%5D=anyor";

Expand Down
6 changes: 4 additions & 2 deletions Web.Api/Controllers/PreachyBudgetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ public class PreachyBudgetController: ControllerBase
{
private readonly AmoService _amoService;
private readonly EnvironmentConfig _envConfig;
private readonly IBackgroundJobClient _backgroundJobClient;

public PreachyBudgetController()
public PreachyBudgetController(IBackgroundJobClient backgroundJobClient)
{
_backgroundJobClient = backgroundJobClient;
_envConfig = new EnvironmentConfig();
_amoService = new AmoService(_envConfig.AmoTokenConfig.AccessToken);
}
Expand All @@ -29,7 +31,7 @@ public async Task<IActionResult> AmoHookHandle()
var streamReader = new StreamReader(Request.Body);
string request = await streamReader.ReadToEndAsync();

BackgroundJob.Enqueue(() => AmoHookHandle(request));
_backgroundJobClient.Enqueue(() => AmoHookHandle(request));
return Ok();
}

Expand Down

0 comments on commit e05f39e

Please sign in to comment.