Skip to content

Commit

Permalink
Add hangfire
Browse files Browse the repository at this point in the history
  • Loading branch information
Варнавский Владимир Николаевич committed Oct 31, 2023
1 parent 2dea152 commit 3b881cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Web.Api/Controllers/PreachyBudgetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using AmoToSheetFunc.Dtos;
using Api.Common;
using Api.Services;
using Hangfire;
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers;
Expand All @@ -26,9 +27,10 @@ public async Task<IActionResult> AmoHookHandle()
if (!Request.Body.CanRead) return BadRequest();

var streamReader = new StreamReader(Request.Body);
var request = await streamReader.ReadToEndAsync();
string request = await streamReader.ReadToEndAsync();

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

[HttpPost("AmoHookHandle/private")]
Expand All @@ -45,7 +47,7 @@ public async Task<IActionResult> AmoHookHandle(string request)
var amount = lead.CustomFieldsValues
.FirstOrDefault(f => f.FieldName == "tinkoff_amount")?.Values
.FirstOrDefault()?.Value;

var sheetDonationService = new SheetDonationsAddService(_envConfig.GoogleCredsJson);
sheetDonationService.AddNewRow(new Donation
{
Expand All @@ -58,6 +60,7 @@ public async Task<IActionResult> AmoHookHandle(string request)
return Ok();
}


private AmoLeadStatusHook ParseHook(string valueToConvert)
{
var unescaped = Uri.UnescapeDataString(valueToConvert);
Expand Down
1 change: 1 addition & 0 deletions Web.Api/Web.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference Include="AspNetCore.Yandex.ObjectStorage" Version="0.2.2" />
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.60.0.2979" />
<PackageReference Include="Hangfire" Version="1.8.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
Expand Down

0 comments on commit 3b881cb

Please sign in to comment.