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 GetInventory(int sku, int storeNumber) { return await _context.PartAvailabilities.FirstOrDefaultAsync(s => s.Store == storeNumber && s.SKU == sku); } public async Task GetPartBySku(string sku) { return await _context.Parts.SingleOrDefaultAsync(p => p.Sku == sku); } public async Task> GetDcfMapping(string partsourceLineCode) { return await _context.DcfMappings .Where(dcf => dcf.LineCode == partsourceLineCode) .ToListAsync(); } } }