12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
-
-
- 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<WcsAction> GetList(WcsAction vo)
- {
- IQueryable<WcsAction> 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<WcsAction> GetById(int id)
- {
- WcsAction action = await _context.WcsActions.FindAsync(id);
- return action;
- }
- //添加详情
- public async Task<bool> Create(WcsAction vo)
- {
- _context.WcsActions.Add(vo);
- await _context.SaveChangesAsync();
- return true;
- }
- //更新详情
- public async Task<bool> Update(WcsAction vo)
- {
- _context.Entry(vo).State = EntityState.Modified;
- try
- {
- await _context.SaveChangesAsync();
- }
- catch (DbUpdateConcurrencyException)
- {
- throw;
- }
- return true;
- }
-
-
- }
- }
|