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