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 CcsActionAddressRepository : ICcsActionAddressRepository { private readonly CcsContext _context; public CcsActionAddressRepository(CcsContext context) { _context = context; } //查询列表 public List GetList(CcsActionAddress vo) { IQueryable actions = _context.CcsActionAddress; if (vo.ActionId != null) { actions = actions.Where(x => x.ActionId == vo.ActionId); } if (!string.IsNullOrEmpty(vo.Type)) { actions = actions.Where(x => x.Type == vo.Type); } return actions.OrderBy(x => x.Sort).ToList(); } //查询详情 public async Task GetById(int id) { CcsActionAddress action = await _context.CcsActionAddress.FindAsync(id); return action; } //添加详情 public async Task Create(CcsActionAddress vo) { _context.CcsActionAddress.Add(vo); await _context.SaveChangesAsync(); return true; } //更新详情 public async Task Update(CcsActionAddress vo) { _context.Entry(vo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return true; } } }