1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
-
- using IMCS.CCS.Entitys;
- using Microsoft.EntityFrameworkCore;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace IMCS.CCS.Repository
- {
- public class CcsActionRepository : ICcsActionRepository
- {
- private readonly CcsContext _context;
- public CcsActionRepository(CcsContext context)
- {
- _context = context;
- }
- //查询列表
- public List<CcsAction> GetList(CcsAction vo)
- {
- IQueryable<CcsAction> actions = _context.CcsAction;
- 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<CcsAction> GetById(int id)
- {
- CcsAction action = await _context.CcsAction.FindAsync(id);
- return action;
- }
- //添加详情
- public async Task<bool> Create(CcsAction vo)
- {
- _context.CcsAction.Add(vo);
- await _context.SaveChangesAsync();
- return true;
- }
- //更新详情
- public async Task<bool> Update(CcsAction vo)
- {
- _context.Entry(vo).State = EntityState.Modified;
- try
- {
- await _context.SaveChangesAsync();
- }
- catch (DbUpdateConcurrencyException)
- {
- throw;
- }
- return true;
- }
-
-
- }
- }
|