Stuff and things

This commit is contained in:
2021-06-29 19:00:13 -04:00
parent 0ff42f148a
commit 962ad3383f
22 changed files with 320 additions and 226 deletions

View File

@@ -0,0 +1,38 @@
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();
}
}
}

View File

@@ -28,8 +28,11 @@
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.15" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Ratermania.Shopify" Version="1.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.ReDoc" Version="5.5.1" />
</ItemGroup>

View File

@@ -106,5 +106,10 @@
<response code="200"><strong>OK:</strong> The engine with the provided EngineConfigId.</response>
<response code="404"><strong>Not Found:</strong> No engine was found matching the provided EngineConfigId.</response>
</member>
<member name="T:PartSource.Api.Controllers.WebhooksController">
<remarks>
This endpoint handles Shopify webhooks
</remarks>
</member>
</members>
</doc>

View File

@@ -6,9 +6,10 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using PartSource.Api.Formatters;
using PartSource.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using PartSource.Data.AutoMapper;
using PartSource.Data.Contexts;
using PartSource.Services;
using System.IO;
@@ -30,6 +31,14 @@ namespace PartSource.Api
{
options.OutputFormatters.RemoveType(typeof(StringOutputFormatter));
options.EnableEndpointRouting = false;
})
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
options.SerializerSettings.ContractResolver = new DefaultContractResolver()
{
NamingStrategy = new SnakeCaseNamingStrategy()
};
});
services.AddSwaggerGen(c =>
@@ -46,6 +55,7 @@ namespace PartSource.Api
services.AddTransient<NexpartService>();
services.AddTransient<SecurityService>();
services.AddTransient<VehicleService>();
services.AddTransient<ShopifyChangelogService>();
services.AddCors(o => o.AddPolicy("Default", builder =>
{
@@ -57,6 +67,9 @@ namespace PartSource.Api
services.AddDbContext<PartSourceContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("PartSourceDatabase"))
);
services.AddDbContext<FitmentContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("FitmentDatabase"))
);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

View File

@@ -1,7 +1,8 @@
{
"ConnectionStrings": {
"PartSourceDatabase": "Server=tcp:ps-whi.database.windows.net,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=ps-whi;Password=9-^*N5dw!6:|.5Q;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
},
"ConnectionStrings": {
"PartSourceDatabase": "Server=tcp:ps-whi.database.windows.net,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=ps-whi;Password=9-^*N5dw!6:|.5Q;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true"
},
"Logging": {
"LogLevel": {
"Default": "Warning"