using WCS.Entitys; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using WCS.Common; namespace WCS.Repository { public class WcsActionAddressRepository : IWcsActionAddressRepository { private readonly ApplicationDbContext _context; public WcsActionAddressRepository(ApplicationDbContext context) { _context = context; } //查询列表 public List GetList(WcsActionAddress vo) { IQueryable actions = _context.WcsActionAddresses; if (vo.ActionId != null) { actions = actions.Where(x => x.ActionId == vo.ActionId); } actions = actions.Where(x => x.Sort == vo.Sort); if (!string.IsNullOrEmpty(vo.Type)) { actions = actions.Where(x => x.Type == vo.Type); } return actions.ToList(); } //查询详情 public async Task GetById(int id) { WcsActionAddress action = await _context.WcsActionAddresses.FindAsync(id); return action; } //添加详情 public async Task Create(WcsActionAddress vo) { _context.WcsActionAddresses.Add(vo); await _context.SaveChangesAsync(); return true; } //更新详情 public async Task Update(WcsActionAddress vo) { _context.Entry(vo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return true; } } }