40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using PartSource.Data;
|
|
using PartSource.Data.Contexts;
|
|
using PartSource.Data.Dtos;
|
|
using PartSource.Data.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PartSource.Services
|
|
{
|
|
public class PartService
|
|
{
|
|
private readonly PartSourceContext _context;
|
|
|
|
public PartService(PartSourceContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<PartsAvailability> GetInventory(int sku, int storeNumber)
|
|
{
|
|
return await _context.PartAvailabilities.FirstOrDefaultAsync(s => s.Store == storeNumber && s.SKU == sku);
|
|
}
|
|
|
|
public async Task<Part> GetPartBySku(string sku)
|
|
{
|
|
return await _context.Parts.SingleOrDefaultAsync(p => p.Sku == sku);
|
|
}
|
|
|
|
public async Task<IList<DcfMapping>> GetDcfMapping(string partsourceLineCode)
|
|
{
|
|
return await _context.DcfMappings
|
|
.Where(dcf => dcf.LineCode == partsourceLineCode)
|
|
.ToListAsync();
|
|
}
|
|
}
|
|
}
|