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 EquipmentMonitorRepository : IEquipmentMonitorRepository { private readonly CcsContext _context; public EquipmentMonitorRepository(CcsContext context) { _context = context; } //查询列表 public async Task> GetList() { IQueryable devices = _context.EquipmentMonitor; List deviceList = await devices.ToListAsync(); return deviceList; } //查询详情 public async Task GetById(long id) { EquipmentMonitor device = await _context.EquipmentMonitor.FindAsync(id); return device; } //添加详情 public async Task Create(EquipmentMonitor vo) { _context.EquipmentMonitor.Add(vo); await _context.SaveChangesAsync(); return true; } //更新详情 public async Task Update(EquipmentMonitor vo) { _context.Entry(vo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return true; } } }