12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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 DictionaryRepository : IDictionaryRepository
- {
- private readonly CcsContext _context;
- public DictionaryRepository(CcsContext context)
- {
- _context = context;
- }
- //查询列表
- public async Task<List<Dictionary>> GetList(Dictionary vo)
- {
- IQueryable<Dictionary> list = _context.Dictionary;
- if (!string.IsNullOrEmpty(vo.Type))
- {
- list = list.Where(x => x.Type == vo.Type);
- }
-
- return await list.ToListAsync();
- }
- //查询详情
- public async Task<Dictionary> GetById(int id)
- {
- Dictionary device = await _context.Dictionary.FindAsync(id);
- return device;
- }
- //添加详情
- public async Task<bool> Create(Dictionary vo)
- {
- _context.Dictionary.Add(vo);
- await _context.SaveChangesAsync();
- return true;
- }
- //更新详情
- public async Task<bool> Update(Dictionary vo)
- {
- _context.Entry(vo).State = EntityState.Modified;
- try
- {
- await _context.SaveChangesAsync();
- }
- catch (DbUpdateConcurrencyException)
- {
- throw;
- }
- return true;
- }
-
-
- }
- }
|