123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
-
- using WCS.Entitys;
- using Microsoft.EntityFrameworkCore;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using WCS.Common;
- namespace WCS.Repository
- {
- public class WcsActionAddressRepository : IWcsActionAddressRepository
- {
- private readonly ApplicationDbContext _context;
- public WcsActionAddressRepository(ApplicationDbContext context)
- {
- _context = context;
- }
- //查询列表
- public List<WcsActionAddress> GetList(WcsActionAddress vo)
- {
- IQueryable<WcsActionAddress> actions = _context.WcsActionAddresses;
- if (vo.ActionId != null)
- {
- actions = actions.Where(x => x.ActionId == vo.ActionId);
- }
- actions = actions.Where(x => x.Sort == vo.Sort);
- if (!string.IsNullOrEmpty(vo.Type))
- {
- actions = actions.Where(x => x.Type == vo.Type);
- }
- return actions.ToList();
- }
- //查询详情
- public async Task<WcsActionAddress> GetById(int id)
- {
- WcsActionAddress action = await _context.WcsActionAddresses.FindAsync(id);
- return action;
- }
- //添加详情
- public async Task<bool> Create(WcsActionAddress vo)
- {
- _context.WcsActionAddresses.Add(vo);
- await _context.SaveChangesAsync();
- return true;
- }
- //更新详情
- public async Task<bool> Update(WcsActionAddress vo)
- {
- _context.Entry(vo).State = EntityState.Modified;
- try
- {
- await _context.SaveChangesAsync();
- }
- catch (DbUpdateConcurrencyException)
- {
- throw;
- }
- return true;
- }
-
-
- }
- }
|