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
{
///
/// This endpoint handles Shopify webhooks
///
[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 OnProductUpdate([FromBody]Product product)
{
await _shopifyChangelogService.AddEntry(product);
return Ok();
}
}
}