Files
Partsource/PartSource.Services/ShopifyChangelogService.cs
2021-06-29 19:00:13 -04:00

35 lines
813 B
C#

using PartSource.Data.Contexts;
using PartSource.Data.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Ratermania.Shopify.Resources;
namespace PartSource.Services
{
public class ShopifyChangelogService
{
private readonly PartSourceContext _partsourceContext;
public ShopifyChangelogService(PartSourceContext partsourceContext)
{
_partsourceContext = partsourceContext;
}
public async Task AddEntry<T>(T data) where T : BaseShopifyResource
{
ShopifyChangelog shopifyChangelog = new ShopifyChangelog
{
ResourceType = typeof(T),
ShopifyId = data.Id,
Data = data,
Timestamp = DateTime.Now
};
await _partsourceContext.AddAsync(shopifyChangelog);
await _partsourceContext.SaveChangesAsync();
}
}
}