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