39 lines
982 B
C#
39 lines
982 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
using PartSource.Data.Dtos;
|
|
using PartSource.Data.Models;
|
|
using PartSource.Services;
|
|
using Ratermania.Shopify.Resources;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PartSource.Api.Controllers
|
|
{
|
|
/// <remarks>
|
|
/// This endpoint handles Shopify webhooks
|
|
/// </remarks>
|
|
[Route("v2/[controller]")]
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName = "v2")]
|
|
public class WebhooksController : BaseApiController
|
|
{
|
|
private readonly ShopifyChangelogService _shopifyChangelogService;
|
|
|
|
public WebhooksController(ShopifyChangelogService shopifyChangelogService)
|
|
{
|
|
_shopifyChangelogService = shopifyChangelogService;
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("products/update")]
|
|
public async Task<ActionResult> OnProductUpdate([FromBody]Product product)
|
|
{
|
|
await _shopifyChangelogService.AddEntry(product);
|
|
|
|
return Ok();
|
|
}
|
|
}
|
|
}
|